From 90f7afcbcfec145619304df9bb1daadf707ef3d8 Mon Sep 17 00:00:00 2001 From: Dan Rubel Date: Sun, 13 Nov 2016 22:03:56 -0500 Subject: [PATCH] flutter doctor show one intellij install per location (#6820) --- packages/flutter_tools/lib/src/doctor.dart | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/packages/flutter_tools/lib/src/doctor.dart b/packages/flutter_tools/lib/src/doctor.dart index 11d93aa9fe..6161d878ef 100644 --- a/packages/flutter_tools/lib/src/doctor.dart +++ b/packages/flutter_tools/lib/src/doctor.dart @@ -302,17 +302,34 @@ abstract class IntelliJValidator extends DoctorValidator { } class IntelliJValidatorOnLinux extends IntelliJValidator { - IntelliJValidatorOnLinux(String title, this.version, this.pluginsPath) : super(title); + IntelliJValidatorOnLinux(String title, this.version, this.installPath, this.pluginsPath) : super(title); @override String version; + final String installPath; + @override String pluginsPath; static Iterable get installed { List validators = []; if (homeDirPath == null) return validators; + + void addValidator(String title, String version, String installPath, String pluginsPath) { + IntelliJValidatorOnLinux validator = + new IntelliJValidatorOnLinux(title, version, installPath, pluginsPath); + for (int index = 0; index < validators.length; ++index) { + DoctorValidator other = validators[index]; + if (other is IntelliJValidatorOnLinux && validator.installPath == other.installPath) { + if (validator.version.compareTo(other.version) > 0) + validators[index] = validator; + return; + } + } + validators.add(validator); + } + for (FileSystemEntity dir in new Directory(homeDirPath).listSync()) { if (dir is Directory) { String name = path.basename(dir.path); @@ -327,7 +344,7 @@ class IntelliJValidatorOnLinux extends IntelliJValidator { } if (installPath != null && FileSystemEntity.isDirectorySync(installPath)) { String pluginsPath = path.join(dir.path, 'config', 'plugins'); - validators.add(new IntelliJValidatorOnLinux(title, version, pluginsPath)); + addValidator(title, version, installPath, pluginsPath); } } });