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

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

Issue 1317023002: show all available import completion suggestions - fixes #23955 (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: merge Created 5 years, 4 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/analysis_server/test/services/completion/import_uri_contributor_test.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/import_uri_contributor.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart b/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart
index 65ed8df54cd6fe49303a8dc6ab303de8da5ed520..b4059723cccf1e9f119a8c0987b591e0180b3d34 100644
--- a/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/import_uri_contributor.dart
@@ -5,7 +5,6 @@
library services.completion.contributor.dart.importuri;
import 'dart:async';
-import 'dart:collection';
import 'dart:core' hide Resource;
import 'package:analysis_server/src/services/completion/dart_completion_manager.dart';
@@ -39,7 +38,6 @@ class ImportUriContributor extends DartCompletionContributor {
class _ImportUriSuggestionBuilder extends SimpleAstVisitor {
final DartCompletionRequest request;
- HashSet<String> _importedUris;
_ImportUriSuggestionBuilder(this.request);
@@ -68,7 +66,6 @@ class _ImportUriSuggestionBuilder extends SimpleAstVisitor {
if (parent is ImportDirective && parent.uri == node) {
String partial = node.literal.lexeme.substring(
node.contentsOffset - node.offset, request.offset - node.offset);
- _computeImportedUris();
request.replacementOffset = node.contentsOffset;
request.replacementLength = node.contentsEnd - node.contentsOffset;
_addDartSuggestions();
@@ -77,7 +74,6 @@ class _ImportUriSuggestionBuilder extends SimpleAstVisitor {
} else if (parent is PartDirective && parent.uri == node) {
String partial = node.literal.lexeme.substring(
node.contentsOffset - node.offset, request.offset - node.offset);
- _computeImportedUris();
request.replacementOffset = node.contentsOffset;
request.replacementLength = node.contentsEnd - node.contentsOffset;
_addFileSuggestions(partial);
@@ -90,7 +86,10 @@ class _ImportUriSuggestionBuilder extends SimpleAstVisitor {
for (SdkLibrary lib in factory.dartSdk.sdkLibraries) {
if (!lib.isInternal && !lib.isImplementation) {
if (!lib.shortName.startsWith('dart:_')) {
- _addSuggestion(lib.shortName);
+ _addSuggestion(lib.shortName,
+ relevance: lib.shortName == 'dart:core'
+ ? DART_RELEVANCE_LOW
+ : DART_RELEVANCE_DEFAULT);
}
}
}
@@ -160,24 +159,15 @@ class _ImportUriSuggestionBuilder extends SimpleAstVisitor {
}
}
- void _addSuggestion(String completion) {
- if (!_importedUris.contains(completion)) {
- request.addSuggestion(new CompletionSuggestion(
- CompletionSuggestionKind.IMPORT, DART_RELEVANCE_DEFAULT, completion,
- completion.length, 0, false, false));
- }
- }
-
- void _computeImportedUris() {
- _importedUris = new HashSet<String>();
- _importedUris.add('dart:core');
- for (Directive directive in request.unit.directives) {
- if (directive is ImportDirective) {
- String uri = directive.uriContent;
- if (uri != null && uri.length > 0) {
- _importedUris.add(uri);
- }
- }
- }
+ void _addSuggestion(String completion,
+ {int relevance: DART_RELEVANCE_DEFAULT}) {
+ request.addSuggestion(new CompletionSuggestion(
+ CompletionSuggestionKind.IMPORT,
+ relevance,
+ completion,
+ completion.length,
+ 0,
+ false,
+ false));
}
}
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/import_uri_contributor_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698