diff --git a/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_imports.dart b/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_imports.dart index dc89d88fe55c..02c498a6666c 100644 --- a/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_imports.dart +++ b/pkg/analysis_server/lib/src/lsp/handlers/custom/handler_imports.dart @@ -140,6 +140,8 @@ class ImportsHandler for (var directive in unit.directives.whereType()) { var import = directive.libraryImport; if (import == null) continue; + var importPrefix = directive.prefix?.name; + if (importPrefix != prefix) continue; var importedElement = prefix == null diff --git a/pkg/analysis_server/test/lsp/import_test.dart b/pkg/analysis_server/test/lsp/import_test.dart index c5d4d5da4130..3ccc01ad99db 100644 --- a/pkg/analysis_server/test/lsp/import_test.dart +++ b/pkg/analysis_server/test/lsp/import_test.dart @@ -317,6 +317,20 @@ Rando^m? r;'''); ); } + Future test_import_multiple() async { + await _verifyGoToImports( + TestCode.parse(''' +import 'dart:async' as import1; +import 'dart:async' as import2; +/*[0*/import 'dart:async';/*0]*/ +/*[1*/import 'dart:core';/*1]*/ +import 'dart:math'; + +Futur^e? f; +'''), + ); + } + Future test_import_part() async { var otherFileUri = Uri.file(join(projectFolderPath, 'lib', 'other.dart')); var main = TestCode.parse('''