Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(399)

Unified Diff: pkg/analysis_server/lib/src/services/completion/dart/library_member_contributor.dart

Issue 2812673002: Add missing checks for null imported/exportedLibraries. (Closed)
Patch Set: Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element_resolver.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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));
+ }
}
}
}
« no previous file with comments | « no previous file | pkg/analyzer/lib/src/generated/element_resolver.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698