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); } } });