Commit 90f7afcb authored by Dan Rubel's avatar Dan Rubel Committed by GitHub

flutter doctor show one intellij install per location (#6820)

parent df25e489
...@@ -302,17 +302,34 @@ abstract class IntelliJValidator extends DoctorValidator { ...@@ -302,17 +302,34 @@ abstract class IntelliJValidator extends DoctorValidator {
} }
class IntelliJValidatorOnLinux extends IntelliJValidator { 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 @override
String version; String version;
final String installPath;
@override @override
String pluginsPath; String pluginsPath;
static Iterable<DoctorValidator> get installed { static Iterable<DoctorValidator> get installed {
List<DoctorValidator> validators = <DoctorValidator>[]; List<DoctorValidator> validators = <DoctorValidator>[];
if (homeDirPath == null) return 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()) { for (FileSystemEntity dir in new Directory(homeDirPath).listSync()) {
if (dir is Directory) { if (dir is Directory) {
String name = path.basename(dir.path); String name = path.basename(dir.path);
...@@ -327,7 +344,7 @@ class IntelliJValidatorOnLinux extends IntelliJValidator { ...@@ -327,7 +344,7 @@ class IntelliJValidatorOnLinux extends IntelliJValidator {
} }
if (installPath != null && FileSystemEntity.isDirectorySync(installPath)) { if (installPath != null && FileSystemEntity.isDirectorySync(installPath)) {
String pluginsPath = path.join(dir.path, 'config', 'plugins'); String pluginsPath = path.join(dir.path, 'config', 'plugins');
validators.add(new IntelliJValidatorOnLinux(title, version, pluginsPath)); addValidator(title, version, installPath, pluginsPath);
} }
} }
}); });
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment