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

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

Issue 1065063002: suggest loadLibrary is import is deferred (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge and remove unused import Created 5 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
Index: pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart b/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
index d31d3d19922dcd69ef223b6e6d365168403a7452..10c69c19643fd8ceef79cc2241f950ef6c125e05 100644
--- a/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/prefixed_element_contributor.dart
@@ -13,7 +13,9 @@ import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
import 'package:analyzer/src/generated/ast.dart';
import 'package:analyzer/src/generated/element.dart';
-import '../../protocol_server.dart' show CompletionSuggestionKind;
+import '../../protocol_server.dart' as protocol;
+import '../../protocol_server.dart'
+ show CompletionSuggestion, CompletionSuggestionKind;
/**
* A contributor for calculating invocation / access suggestions
@@ -303,8 +305,6 @@ class _PrefixedIdentifierSuggestionBuilder
@override
Future<bool> visitPrefixElement(PrefixElement element) {
- //TODO (danrubel) reimplement to use prefixElement.importedLibraries
- // once that accessor is implemented and available in Dart
bool modified = false;
// Find the import directive with the given prefix
for (Directive directive in request.unit.directives) {
@@ -317,6 +317,22 @@ class _PrefixedIdentifierSuggestionBuilder
CompletionSuggestionKind.INVOCATION, library,
request.target.containingNode.parent is TypeName);
modified = true;
+ if (directive.deferredKeyword != null) {
+ String completion = 'loadLibrary';
+ CompletionSuggestion suggestion = new CompletionSuggestion(
+ CompletionSuggestionKind.INVOCATION, DART_RELEVANCE_DEFAULT,
+ completion, completion.length, 0, false, false,
+ parameterNames: [],
+ parameterTypes: [],
+ requiredParameterCount: 0,
+ hasNamedParameters: false,
+ returnType: 'void');
+ suggestion.element = new protocol.Element(
+ protocol.ElementKind.FUNCTION, completion,
+ protocol.Element.makeFlags(),
+ parameters: '()', returnType: 'void');
+ request.addSuggestion(suggestion);
+ }
}
}
}

Powered by Google App Engine
This is Rietveld 408576698