Index: pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
index b97fb61d07ad1b16e316a41b43ac47964020223b..a6f30996f764cb4478efd28223f74ccd7307b9ab 100644 |
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart |
@@ -1339,6 +1339,7 @@ class FixProcessor { |
} |
// may be there is an existing import, |
// but it is with prefix and we don't use this prefix |
+ Set<Source> alreadyImportedWithPrefix = new Set<Source>(); |
for (ImportElement imp in unitLibraryElement.imports) { |
// prepare element |
LibraryElement libraryElement = imp.importedLibrary; |
@@ -1375,13 +1376,13 @@ class FixProcessor { |
if (libraryElement.isInSdk) { |
libraryName = imp.uri; |
} |
+ // don't add this library again |
+ alreadyImportedWithPrefix.add(libraryElement.source); |
// update library |
String newShowCode = 'show ${StringUtils.join(showNames, ", ")}'; |
_addReplaceEdit( |
rf.rangeOffsetEnd(showCombinator), newShowCode, unitLibraryElement); |
_addFix(DartFixKind.IMPORT_LIBRARY_SHOW, [libraryName]); |
- // we support only one import without prefix |
- return; |
} |
} |
// check SDK libraries |
@@ -1422,6 +1423,10 @@ class FixProcessor { |
if (librarySource.isInSystemLibrary) { |
continue; |
} |
+ // maybe already imported with a prefix |
+ if (alreadyImportedWithPrefix.contains(librarySource)) { |
+ continue; |
+ } |
// prepare LibraryElement |
LibraryElement libraryElement = |
context.getLibraryElement(librarySource); |