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

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

Issue 1027693007: exclude identifier being completed from list of suggestions (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 9 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/local_computer_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/local_computer.dart
diff --git a/pkg/analysis_server/lib/src/services/completion/local_computer.dart b/pkg/analysis_server/lib/src/services/completion/local_computer.dart
index 028b11660757bb96077fd800ae5434aa3719cf78..5602d81c060f02c8040d5f4a4a03d80408581a2f 100644
--- a/pkg/analysis_server/lib/src/services/completion/local_computer.dart
+++ b/pkg/analysis_server/lib/src/services/completion/local_computer.dart
@@ -429,6 +429,11 @@ class _LocalVisitor extends LocalDeclarationVisitor {
final DartCompletionRequest request;
final OpType optype;
+ /**
+ * The simple identifier that is being completed, or `null` if none.
+ */
+ SimpleIdentifier targetId;
+
_LocalVisitor(this.request, int offset, this.optype) : super(offset);
@override
@@ -626,6 +631,13 @@ class _LocalVisitor extends LocalDeclarationVisitor {
}
}
+ @override
+ void visitSimpleIdentifier(SimpleIdentifier node) {
+ // Record the visited identifier so as not to suggest it
+ targetId = node;
+ return super.visitSimpleIdentifier(node);
+ }
+
void _addParameterInfo(
CompletionSuggestion suggestion, FormalParameterList parameters) {
var paramList = parameters.parameters;
@@ -664,7 +676,7 @@ class _LocalVisitor extends LocalDeclarationVisitor {
CompletionSuggestion _addSuggestion(SimpleIdentifier id, TypeName returnType,
bool isDeprecated, int defaultRelevance, {ClassDeclaration classDecl}) {
- if (id != null) {
+ if (id != null && !identical(id, targetId)) {
String completion = id.name;
if (completion != null && completion.length > 0 && completion != '_') {
CompletionSuggestion suggestion = new CompletionSuggestion(
« no previous file with comments | « no previous file | pkg/analysis_server/test/services/completion/local_computer_test.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698