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

Unified Diff: pkg/analysis_services/lib/src/completion/imported_type_computer.dart

Issue 460333003: do not suggest types when editing a name in a variable declaration (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 6 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_services/lib/src/completion/local_computer.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_services/lib/src/completion/imported_type_computer.dart
diff --git a/pkg/analysis_services/lib/src/completion/imported_type_computer.dart b/pkg/analysis_services/lib/src/completion/imported_type_computer.dart
index 959f4b4effab062a17732f3b56274a2be65172d9..29514156c8fa412335141e4a8f512744800c3d36 100644
--- a/pkg/analysis_services/lib/src/completion/imported_type_computer.dart
+++ b/pkg/analysis_services/lib/src/completion/imported_type_computer.dart
@@ -32,7 +32,7 @@ class ImportedTypeComputer extends CompletionComputer {
Future<bool> computeFull(CompilationUnit unit, AstNode node,
List<CompletionSuggestion> suggestions) {
return node.accept(
- new _ImportedTypeVisitor(searchEngine, unit, suggestions));
+ new _ImportedTypeVisitor(searchEngine, unit, offset, suggestions));
}
}
@@ -43,9 +43,11 @@ class ImportedTypeComputer extends CompletionComputer {
class _ImportedTypeVisitor extends GeneralizingAstVisitor<Future<bool>> {
final SearchEngine searchEngine;
final CompilationUnit unit;
+ final int offset;
final List<CompletionSuggestion> suggestions;
- _ImportedTypeVisitor(this.searchEngine, this.unit, this.suggestions);
+ _ImportedTypeVisitor(this.searchEngine, this.unit, this.offset,
+ this.suggestions);
Future<bool> visitCombinator(Combinator node) {
var directive = node.getAncestor((parent) => parent is NamespaceDirective);
@@ -63,6 +65,15 @@ class _ImportedTypeVisitor extends GeneralizingAstVisitor<Future<bool>> {
return node.parent.accept(this);
}
+ Future<bool> visitVariableDeclaration(VariableDeclaration node) {
+ // Do not add suggestions if editing the name in a var declaration
+ SimpleIdentifier name = node.name;
+ if (name == null || name.offset < offset || offset > name.end) {
+ return visitNode(node);
+ }
+ return new Future.value(false);
+ }
+
Future<bool> _addImportedElements() {
var future = searchEngine.searchTopLevelDeclarations('');
return future.then((List<SearchMatch> matches) {
« no previous file with comments | « no previous file | pkg/analysis_services/lib/src/completion/local_computer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698