Small optimization in named_constructor_contributor.dart to not reference the libraryElement until we know that the contributor will be used.

Change-Id: Ic0624568bd8ae4caec6f49c9ea132fcd17230b95
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/150167
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Jaime Wren <jwren@google.com>
This commit is contained in:
Jaime Wren 2020-06-05 15:03:54 +00:00 committed by commit-bot@chromium.org
parent 48d105a551
commit fbfb3a29c5

View file

@ -19,13 +19,11 @@ class NamedConstructorContributor extends DartCompletionContributor {
Future<List<CompletionSuggestion>> computeSuggestions(
DartCompletionRequest request, SuggestionBuilder builder) async {
var node = request.target.containingNode;
var libraryElement = request.libraryElement;
if (libraryElement == null) {
return const <CompletionSuggestion>[];
}
// Build the list of suggestions
if (node is ConstructorName) {
var libraryElement = request.libraryElement;
if (libraryElement == null) {
return const <CompletionSuggestion>[];
}
var typeName = node.type;
if (typeName != null) {
var type = typeName.type;