Unverified Commit 0cb6a03d authored by Chuan-Yen Chiang's avatar Chuan-Yen Chiang Committed by GitHub

fix: duplicated Intellij IDE message when running flutter doctor (#129030)

This PR fixes the duplicated message from `flutter doctor` when install `Intellij IDE` from `JetBrains Toolbox`. 

The solution is based on the #98276. Add a function to skip the creation of the validator for `Mac` when the key word `JetBrainsToolboxApp` is in the `info.plist`.

Before: 
<img width="918" alt="Screenshot 2023-06-16 at 21 04 43" src="https://github.com/flutter/flutter/assets/3291319/2f5ef0c6-0d29-4d02-97ed-257f29965a1a">

After: 
<img width="924" alt="Screenshot 2023-06-16 at 21 13 15" src="https://github.com/flutter/flutter/assets/3291319/dcdca845-41a1-4896-a5ac-5bca724af676">

fix #98276
parent e3b5ae56
...@@ -376,6 +376,7 @@ class IntelliJValidatorOnMac extends IntelliJValidator { ...@@ -376,6 +376,7 @@ class IntelliJValidatorOnMac extends IntelliJValidator {
'IntelliJ IDEA.app': _ultimateEditionId, 'IntelliJ IDEA.app': _ultimateEditionId,
'IntelliJ IDEA Ultimate.app': _ultimateEditionId, 'IntelliJ IDEA Ultimate.app': _ultimateEditionId,
'IntelliJ IDEA CE.app': _communityEditionId, 'IntelliJ IDEA CE.app': _communityEditionId,
'IntelliJ IDEA Community Edition.app': _communityEditionId,
}; };
static Iterable<DoctorValidator> installed({ static Iterable<DoctorValidator> installed({
...@@ -482,6 +483,17 @@ class IntelliJValidatorOnMac extends IntelliJValidator { ...@@ -482,6 +483,17 @@ class IntelliJValidatorOnMac extends IntelliJValidator {
]), ]),
)); ));
} }
// Remove JetBrains Toolbox link apps. These tiny apps just
// link to the full app, will get detected elsewhere in our search.
validators.removeWhere((DoctorValidator validator) {
final String identifierKey = plistParser.getValueFromFile(
(validator as IntelliJValidatorOnMac).plistFile,
PlistParser.kCFBundleIdentifierKey,
) as String;
return identifierKey.contains('com.jetbrains.toolbox.linkapp');
});
return validators; return validators;
} }
......
...@@ -305,6 +305,7 @@ void main() { ...@@ -305,6 +305,7 @@ void main() {
processManager: processManager, processManager: processManager,
plistParser: FakePlistParser(<String, String>{ plistParser: FakePlistParser(<String, String>{
PlistParser.kCFBundleShortVersionStringKey: '2020.10', PlistParser.kCFBundleShortVersionStringKey: '2020.10',
PlistParser.kCFBundleIdentifierKey: 'com.jetbrains.intellij',
}), }),
).whereType<IntelliJValidatorOnMac>(); ).whereType<IntelliJValidatorOnMac>();
expect(validators.length, 2); expect(validators.length, 2);
...@@ -371,6 +372,47 @@ void main() { ...@@ -371,6 +372,47 @@ void main() {
expect(validator.pluginsPath, '/path/to/JetBrainsToolboxApp.plugins'); expect(validator.pluginsPath, '/path/to/JetBrainsToolboxApp.plugins');
}); });
testWithoutContext('Remove JetBrains Toolbox', () async {
final FileSystem fileSystem = MemoryFileSystem.test();
final List<String> installPaths = <String>[
fileSystem.path.join('/', 'foo', 'bar', 'Applications',
'JetBrains Toolbox', 'IntelliJ IDEA Ultimate.app'),
fileSystem.path.join('/', 'foo', 'bar', 'Applications',
'JetBrains Toolbox', 'IntelliJ IDEA Community Edition.app')
];
for (final String installPath in installPaths) {
fileSystem.directory(installPath).createSync(recursive: true);
}
final FakeProcessManager processManager =
FakeProcessManager.list(<FakeCommand>[
const FakeCommand(command: <String>[
'mdfind',
'kMDItemCFBundleIdentifier="com.jetbrains.intellij.ce"',
], stdout: 'skip'),
const FakeCommand(command: <String>[
'mdfind',
'kMDItemCFBundleIdentifier="com.jetbrains.intellij*"',
], stdout: 'skip')
]);
final Iterable<DoctorValidator> installed =
IntelliJValidatorOnMac.installed(
fileSystem: fileSystem,
fileSystemUtils:
FileSystemUtils(fileSystem: fileSystem, platform: macPlatform),
userMessages: UserMessages(),
plistParser: FakePlistParser(<String, String>{
'JetBrainsToolboxApp': '/path/to/JetBrainsToolboxApp',
'CFBundleIdentifier': 'com.jetbrains.toolbox.linkapp',
}),
processManager: processManager,
);
expect(installed.length, 0);
});
} }
class IntelliJValidatorTestTarget extends IntelliJValidator { class IntelliJValidatorTestTarget extends IntelliJValidator {
......
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