diff --git a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_manager.dart b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_manager.dart index 6ac0ae1fb0ba..fb5138ca8f1b 100644 --- a/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_manager.dart +++ b/pkg/analysis_server/lib/src/services/correction/fix/data_driven/transform_set_manager.dart @@ -49,7 +49,7 @@ class TransformSetManager { var packages = package.packagesAvailableTo(libraryPath); for (var package in packages.packages) { var folder = package.libFolder; - transformSets.addAll(fromFolder(folder)); + transformSets.addAll(fromFolder(folder, packageName: package.name)); } if (_sdkCache != null) { transformSets.add(_sdkCache!); diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart index 2e5edb113422..5af867d89592 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/transform_set_manager_test.dart @@ -29,6 +29,33 @@ class TransformSetManagerTest extends AbstractContextTest { manager.clearCache(); } + Future test_package_folder_with_version() async { + _addDataFile('p1-1.0'); + + writeTestPackageConfig( + config: PackageConfigFileBuilder() + ..add(name: 'p1', rootPath: '$workspaceRootPath/p1-1.0')); + + newFile('/home/test/pubspec.yaml', ''); + + var testFile = convertPath('$testPackageLibPath/test.dart'); + newFile(testFile, ''); + var result = await (await session).getResolvedLibraryValid(testFile); + var sets = manager.forLibrary(result.element); + expect(sets, hasLength(1)); + var elementMatcher = ElementMatcher( + importedUris: [Uri.parse('package:p1/test.dart')], + components: ['A'], + kinds: [ElementKind.classKind]); + + var set = sets.first.transformsFor(elementMatcher, applyingBulkFixes: true); + expect(set, isNotEmpty); + expect( + set.first.element.libraryUris.first.path, + equals('p1/test.dart'), + ); + } + Future test_twoFiles_onePackage() async { var folder = '$workspaceRootPath/p1/lib/fix_data';