Index: pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart |
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart |
index 9a98987c00215f95f175ae86a8f5d0236d245d65..1e87b11804d336594c7d7008ba663491b9f442af 100644 |
--- a/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart |
+++ b/pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart |
@@ -56,26 +56,27 @@ class LibraryMemberContributor extends DartCompletionContributor { |
for (ImportElement importElem in imports) { |
if (importElem.prefix?.name == elem.name) { |
LibraryElement library = importElem.importedLibrary; |
+ if (library != null) { |
+ // Suggest elements from the imported library |
+ AstNode parent = request.target.containingNode.parent; |
+ bool isConstructor = parent.parent is ConstructorName; |
+ bool typesOnly = parent is TypeName; |
+ bool instCreation = typesOnly && isConstructor; |
+ LibraryElementSuggestionBuilder builder = |
+ new LibraryElementSuggestionBuilder( |
+ containingLibrary, |
+ CompletionSuggestionKind.INVOCATION, |
+ typesOnly, |
+ instCreation, |
+ request.ideOptions); |
+ library.visitChildren(builder); |
+ suggestions.addAll(builder.suggestions); |
- // Suggest elements from the imported library |
- AstNode parent = request.target.containingNode.parent; |
- bool isConstructor = parent.parent is ConstructorName; |
- bool typesOnly = parent is TypeName; |
- bool instCreation = typesOnly && isConstructor; |
- LibraryElementSuggestionBuilder builder = |
- new LibraryElementSuggestionBuilder( |
- containingLibrary, |
- CompletionSuggestionKind.INVOCATION, |
- typesOnly, |
- instCreation, |
- request.ideOptions); |
- library.visitChildren(builder); |
- suggestions.addAll(builder.suggestions); |
- |
- // If the import is 'deferred' then suggest 'loadLibrary' |
- if (importElem.isDeferred) { |
- FunctionElement loadLibFunct = library.loadLibraryFunction; |
- suggestions.add(createSuggestion(loadLibFunct, request.ideOptions)); |
+ // If the import is 'deferred' then suggest 'loadLibrary' |
+ if (importElem.isDeferred) { |
+ FunctionElement loadLibFunct = library.loadLibraryFunction; |
+ suggestions.add(createSuggestion(loadLibFunct, request.ideOptions)); |
+ } |
} |
} |
} |