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

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

Issue 1498733005: convert uri contributor to use new task model (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years 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/dart_completion_manager.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart b/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart
index 2f32fb72e042f97a3fe78005873d6a8f3abbbe85..a34fb3cb3eb9b71713e918eac34a8facf9c7a0d6 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart_completion_manager.dart
@@ -20,7 +20,6 @@ import 'package:analysis_server/src/services/completion/imported_reference_contr
import 'package:analysis_server/src/services/completion/local_reference_contributor.dart';
import 'package:analysis_server/src/services/completion/optype.dart';
import 'package:analysis_server/src/services/completion/prefixed_element_contributor.dart';
-import 'package:analysis_server/src/services/completion/uri_contributor.dart';
import 'package:analysis_server/src/services/search/search_engine.dart';
import 'package:analyzer/file_system/file_system.dart';
import 'package:analyzer/src/generated/ast.dart';
@@ -102,7 +101,7 @@ class DartCompletionManager extends CompletionManager {
//new ArgListContributor(),
new CombinatorContributor(),
new PrefixedElementContributor(),
- new UriContributor(),
+ //new UriContributor(),
// TODO(brianwilkerson) Use the completion contributor extension point
// to add the contributor below (and eventually, all the contributors).
// new NewCompletionWrapper(new InheritedContributor())
@@ -447,6 +446,10 @@ class ReplacementRange {
bool isKeywordOrIdentifier(Token token) =>
token.type == TokenType.KEYWORD || token.type == TokenType.IDENTIFIER;
+ //TODO(danrubel) Ideally this needs to be pushed down into the contributors
+ // but that implies that each suggestion can have a different
+ // replacement offsent/length which would mean an API change
+
var entity = target.entity;
Token token = entity is AstNode ? entity.beginToken : entity;
if (token != null && requestOffset < token.offset) {
@@ -461,9 +464,27 @@ class ReplacementRange {
}
if (token != null && isKeywordOrIdentifier(token)) {
if (token.offset <= requestOffset && requestOffset <= token.end) {
+ // Replacement range for typical identifier completion
return new ReplacementRange(token.offset, token.length);
}
}
+ if (token is StringToken) {
+ SimpleStringLiteral uri = new SimpleStringLiteral(token, token.lexeme);
+ Token previous = token.previous;
+ if (previous is KeywordToken) {
+ Keyword keyword = previous.keyword;
+ if (keyword == Keyword.IMPORT ||
+ keyword == Keyword.EXPORT ||
+ keyword == Keyword.PART) {
+ int start = uri.contentsOffset;
+ var end = uri.contentsEnd;
+ if (start <= requestOffset && requestOffset <= end) {
+ // Replacement range for import URI
+ return new ReplacementRange(start, end - start);
+ }
+ }
+ }
+ }
}
return new ReplacementRange(requestOffset, 0);
}

Powered by Google App Engine
This is Rietveld 408576698