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

Side by Side Diff: pkg/analysis_server/lib/src/services/completion/imported_computer.dart

Issue 802233002: refine when suggestions are limited to types (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 6 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library services.completion.computer.dart.toplevel; 5 library services.completion.computer.dart.toplevel;
6 6
7 import 'dart:async'; 7 import 'dart:async';
8 import 'dart:collection'; 8 import 'dart:collection';
9 9
10 import 'package:analysis_server/src/protocol_server.dart' hide Element, 10 import 'package:analysis_server/src/protocol_server.dart' hide Element,
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 return node.parent.accept(this); 189 return node.parent.accept(this);
190 } 190 }
191 191
192 @override 192 @override
193 _ImportedSuggestionBuilder visitStringLiteral(StringLiteral node) { 193 _ImportedSuggestionBuilder visitStringLiteral(StringLiteral node) {
194 return null; 194 return null;
195 } 195 }
196 196
197 @override 197 @override
198 _ImportedSuggestionBuilder visitTypeName(TypeName node) { 198 _ImportedSuggestionBuilder visitTypeName(TypeName node) {
199 return new _ImportedSuggestionBuilder(request, typesOnly: true); 199 bool typesOnly = false;
200 // If suggesting completions within a TypeName node
201 // then limit suggestions to only types in specific situations
202 AstNode p = node.parent;
203 if (p is IsExpression || p is ConstructorName || p is AsExpression) {
204 typesOnly = true;
205 } else if (p is VariableDeclarationList) {
206 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS
207 // the user may be either (1) entering a type for the assignment
208 // or (2) starting a new statement.
209 // Consider suggesting only types
210 // if only spaces separates the 1st and 2nd identifiers.
211 }
212 return new _ImportedSuggestionBuilder(request, typesOnly: typesOnly);
200 } 213 }
201 214
202 @override 215 @override
203 _ImportedSuggestionBuilder 216 _ImportedSuggestionBuilder
204 visitVariableDeclaration(VariableDeclaration node) { 217 visitVariableDeclaration(VariableDeclaration node) {
205 Token equals = node.equals; 218 Token equals = node.equals;
206 // Make suggestions for the RHS of a variable declaration 219 // Make suggestions for the RHS of a variable declaration
207 if (equals != null && request.offset >= equals.end) { 220 if (equals != null && request.offset >= equals.end) {
208 return new _ImportedSuggestionBuilder(request, excludeVoidReturn: true); 221 return new _ImportedSuggestionBuilder(request, excludeVoidReturn: true);
209 } 222 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 addFilteredSuggestions(cache.importedTypeSuggestions); 365 addFilteredSuggestions(cache.importedTypeSuggestions);
353 addFilteredSuggestions(cache.libraryPrefixSuggestions); 366 addFilteredSuggestions(cache.libraryPrefixSuggestions);
354 if (!typesOnly) { 367 if (!typesOnly) {
355 addFilteredSuggestions(cache.otherImportedSuggestions); 368 addFilteredSuggestions(cache.otherImportedSuggestions);
356 if (!excludeVoidReturn) { 369 if (!excludeVoidReturn) {
357 addFilteredSuggestions(cache.importedVoidReturnSuggestions); 370 addFilteredSuggestions(cache.importedVoidReturnSuggestions);
358 } 371 }
359 } 372 }
360 } 373 }
361 } 374 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698