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

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: merge and address comments 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
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/local_computer.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 // TODO (danrubel) refactor this and local_computer
200 // to reduce duplicate code
201 bool typesOnly = false;
202 // If suggesting completions within a TypeName node
203 // then limit suggestions to only types in specific situations
204 AstNode p = node.parent;
205 if (p is IsExpression || p is ConstructorName || p is AsExpression) {
206 typesOnly = true;
207 } else if (p is VariableDeclarationList) {
208 // TODO (danrubel) When entering 1st of 2 identifiers on assignment LHS
209 // the user may be either (1) entering a type for the assignment
210 // or (2) starting a new statement.
211 // Consider suggesting only types
212 // if only spaces separates the 1st and 2nd identifiers.
213 }
214 return new _ImportedSuggestionBuilder(request, typesOnly: typesOnly);
200 } 215 }
201 216
202 @override 217 @override
203 _ImportedSuggestionBuilder 218 _ImportedSuggestionBuilder
204 visitVariableDeclaration(VariableDeclaration node) { 219 visitVariableDeclaration(VariableDeclaration node) {
205 Token equals = node.equals; 220 Token equals = node.equals;
206 // Make suggestions for the RHS of a variable declaration 221 // Make suggestions for the RHS of a variable declaration
207 if (equals != null && request.offset >= equals.end) { 222 if (equals != null && request.offset >= equals.end) {
208 return new _ImportedSuggestionBuilder(request, excludeVoidReturn: true); 223 return new _ImportedSuggestionBuilder(request, excludeVoidReturn: true);
209 } 224 }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 addFilteredSuggestions(cache.importedTypeSuggestions); 367 addFilteredSuggestions(cache.importedTypeSuggestions);
353 addFilteredSuggestions(cache.libraryPrefixSuggestions); 368 addFilteredSuggestions(cache.libraryPrefixSuggestions);
354 if (!typesOnly) { 369 if (!typesOnly) {
355 addFilteredSuggestions(cache.otherImportedSuggestions); 370 addFilteredSuggestions(cache.otherImportedSuggestions);
356 if (!excludeVoidReturn) { 371 if (!excludeVoidReturn) {
357 addFilteredSuggestions(cache.importedVoidReturnSuggestions); 372 addFilteredSuggestions(cache.importedVoidReturnSuggestions);
358 } 373 }
359 } 374 }
360 } 375 }
361 } 376 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/lib/src/services/completion/local_computer.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698