From 4c35308ccfc6ba1137ec532c57d64a9b219ed680 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kamil=20Szcz=C4=99k?= Date: Tue, 18 Mar 2025 10:35:34 +0100 Subject: [PATCH] fix(doctor): add an alternative path for the Dart plugin (#163215) It seems like with some recent plugin/IDE version, the path for the Dart plugin has changed from `/Dart` to `/dart`, causing `flutter doctor` to incorrectly assume that the plugin is not installed. Add `dart` as an alternative to the existing `Dart` package name. Fixes #163214. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [ ] I updated/added relevant documentation (doc comments with `///`). - [ ] I added new tests to check the change I am making, or this PR is [test-exempt]. - [ ] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing. If you need help, consider asking for advice on the #hackers-new channel on [Discord]. [Contributor Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#overview [Tree Hygiene]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md [test-exempt]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#tests [Flutter Style Guide]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md [Features we expect every widget to implement]: https://github.com/flutter/flutter/blob/main/docs/contributing/Style-guide-for-Flutter-repo.md#features-we-expect-every-widget-to-implement [CLA]: https://cla.developers.google.com/ [flutter/tests]: https://github.com/flutter/tests [breaking change policy]: https://github.com/flutter/flutter/blob/main/docs/contributing/Tree-hygiene.md#handling-breaking-changes [Discord]: https://github.com/flutter/flutter/blob/main/docs/contributing/Chat.md [Data Driven Fixes]: https://github.com/flutter/flutter/blob/main/docs/contributing/Data-driven-Fixes.md --- .../src/android/android_studio_validator.dart | 2 +- .../lib/src/intellij/intellij_validator.dart | 2 +- .../general.shard/intellij/intellij_test.dart | 35 ++++++++++++++++--- 3 files changed, 33 insertions(+), 6 deletions(-) diff --git a/packages/flutter_tools/lib/src/android/android_studio_validator.dart b/packages/flutter_tools/lib/src/android/android_studio_validator.dart index b2bf7fb9a4..76bfc9b30e 100644 --- a/packages/flutter_tools/lib/src/android/android_studio_validator.dart +++ b/packages/flutter_tools/lib/src/android/android_studio_validator.dart @@ -76,7 +76,7 @@ class AndroidStudioValidator extends DoctorValidator { ); plugins.validatePackage( messages, - ['Dart'], + ['Dart', 'dart'], 'Dart', IntelliJPlugins.kIntellijDartPluginUrl, ); diff --git a/packages/flutter_tools/lib/src/intellij/intellij_validator.dart b/packages/flutter_tools/lib/src/intellij/intellij_validator.dart index 2ce0709dc8..5e986f4b27 100644 --- a/packages/flutter_tools/lib/src/intellij/intellij_validator.dart +++ b/packages/flutter_tools/lib/src/intellij/intellij_validator.dart @@ -109,7 +109,7 @@ abstract class IntelliJValidator extends DoctorValidator { ); plugins.validatePackage( messages, - ['Dart'], + ['Dart', 'dart'], 'Dart', IntelliJPlugins.kIntellijDartPluginUrl, ); diff --git a/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart b/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart index 0c77614d84..4cc2f8dab2 100644 --- a/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart +++ b/packages/flutter_tools/test/general.shard/intellij/intellij_test.dart @@ -52,7 +52,7 @@ void main() { ); final List messages = []; - plugins.validatePackage(messages, ['Dart'], 'Dart', 'download-Dart'); + plugins.validatePackage(messages, ['Dart', 'dart'], 'Dart', 'download-Dart'); plugins.validatePackage( messages, ['flutter-intellij', 'flutter-intellij.jar'], @@ -156,7 +156,7 @@ Manifest-Version: 1.0 final IntelliJPlugins plugins = IntelliJPlugins(_kPluginsPath, fileSystem: fileSystem); final List messages = []; - plugins.validatePackage(messages, ['Dart'], 'Dart', 'download-Dart'); + plugins.validatePackage(messages, ['Dart', 'dart'], 'Dart', 'download-Dart'); plugins.validatePackage( messages, ['flutter-intellij', 'flutter-intellij.jar'], @@ -188,11 +188,38 @@ Manifest-Version: 1.0 ); expect( - () => - plugins.validatePackage([], ['Dart'], 'Dart', 'download-Dart'), + () => plugins.validatePackage( + [], + ['Dart', 'dart'], + 'Dart', + 'download-Dart', + ), returnsNormally, ); }); + + // Regression test for https://github.com/flutter/flutter/issues/163214 + testWithoutContext( + 'IntelliJPlugins can find the Dart plugin with a lowercase package name', + () async { + final IntelliJPlugins plugins = IntelliJPlugins(_kPluginsPath, fileSystem: fileSystem); + final Archive dartJarArchive = buildSingleFileArchive('META-INF/plugin.xml', r''' + + Dart + 242.24931 +'''); + writeFileCreatingDirectories( + fileSystem.path.join(_kPluginsPath, 'dart', 'lib', 'dart.jar'), + ZipEncoder().encode(dartJarArchive)!, + ); + + final List messages = []; + plugins.validatePackage(messages, ['Dart', 'dart'], 'Dart', 'download-Dart'); + + expect(messages.length, equals(1)); + expect(messages.single.message, equals('Dart plugin version 242.24931')); + }, + ); } const String _kPluginsPath = '/data/intellij/plugins';