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

Unified Diff: pkg/analysis_server/lib/src/provisional/completion/dart/completion_target.dart

Issue 1407273004: next step toward completion plugin API (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: address comments Created 5 years, 2 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/provisional/completion/dart/completion_target.dart
diff --git a/pkg/analysis_server/lib/src/provisional/completion/dart/completion_target.dart b/pkg/analysis_server/lib/src/provisional/completion/dart/completion_target.dart
index e94016a39bf151d63134fe434c597eac273671b5..0cb00352af79b6af379e9bee3aaac8104a2c9f65 100644
--- a/pkg/analysis_server/lib/src/provisional/completion/dart/completion_target.dart
+++ b/pkg/analysis_server/lib/src/provisional/completion/dart/completion_target.dart
@@ -86,6 +86,11 @@ int _computeArgIndex(AstNode containingNode, Object entity) {
*/
class CompletionTarget {
/**
+ * The compilation unit in which the completion is occurring.
+ */
+ final CompilationUnit unit;
+
+ /**
* The context in which the completion is occurring. This is the AST node
* which is a direct parent of [entity].
*/
@@ -156,10 +161,12 @@ class CompletionTarget {
// Try to replace with a comment token.
Token commentToken = _getContainingCommentToken(entity, offset);
if (commentToken != null) {
- return new CompletionTarget._(containingNode, commentToken, true);
+ return new CompletionTarget._(
+ compilationUnit, containingNode, commentToken, true);
}
// Target found.
- return new CompletionTarget._(containingNode, entity, false);
+ return new CompletionTarget._(
+ compilationUnit, containingNode, entity, false);
} else {
// Since entity is a token, we don't need to look inside it; just
// proceed to the next entity.
@@ -189,10 +196,11 @@ class CompletionTarget {
containingNode = docComment;
} else {
return new CompletionTarget._(
- compilationUnit, commentToken, true);
+ compilationUnit, compilationUnit, commentToken, true);
}
}
- return new CompletionTarget._(containingNode, entity, false);
+ return new CompletionTarget._(
+ compilationUnit, containingNode, entity, false);
}
// Otherwise, the completion target is somewhere inside the entity,
@@ -216,7 +224,8 @@ class CompletionTarget {
// Since no completion target was found, we set the completion target
// entity to null and use the compilationUnit as the parent.
- return new CompletionTarget._(compilationUnit, null, false);
+ return new CompletionTarget._(
+ compilationUnit, compilationUnit, null, false);
}
}
@@ -224,7 +233,8 @@ class CompletionTarget {
* Create a [CompletionTarget] holding the given [containingNode] and
* [entity].
*/
- CompletionTarget._(AstNode containingNode, Object entity, this.isCommentText)
+ CompletionTarget._(
+ this.unit, AstNode containingNode, Object entity, this.isCommentText)
: this.containingNode = containingNode,
this.entity = entity,
this.argIndex = _computeArgIndex(containingNode, entity);

Powered by Google App Engine
This is Rietveld 408576698