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

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

Issue 1050743003: replace request.node with request.target.containingNode in more situations (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: merge Created 5 years, 8 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 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' 10 import 'package:analysis_server/src/protocol_server.dart'
(...skipping 21 matching lines...) Expand all
32 OpType optype = request.optype; 32 OpType optype = request.optype;
33 if (optype.includeReturnValueSuggestions || 33 if (optype.includeReturnValueSuggestions ||
34 optype.includeTypeNameSuggestions || 34 optype.includeTypeNameSuggestions ||
35 optype.includeVoidReturnSuggestions || 35 optype.includeVoidReturnSuggestions ||
36 optype.includeConstructorSuggestions) { 36 optype.includeConstructorSuggestions) {
37 builder = new _ImportedSuggestionBuilder(request, optype); 37 builder = new _ImportedSuggestionBuilder(request, optype);
38 builder.shouldWaitForLowPrioritySuggestions = 38 builder.shouldWaitForLowPrioritySuggestions =
39 shouldWaitForLowPrioritySuggestions; 39 shouldWaitForLowPrioritySuggestions;
40 // If target is an argument in an argument list 40 // If target is an argument in an argument list
41 // then suggestions may need to be adjusted 41 // then suggestions may need to be adjusted
42 suggestionsComputed = builder.computeFast(request.node); 42 suggestionsComputed = builder.computeFast(request.target.containingNode);
43 return suggestionsComputed && request.target.argIndex == null; 43 return suggestionsComputed && request.target.argIndex == null;
44 } 44 }
45 return true; 45 return true;
46 } 46 }
47 47
48 @override 48 @override
49 Future<bool> computeFull(DartCompletionRequest request) { 49 Future<bool> computeFull(DartCompletionRequest request) async {
50 if (builder != null) { 50 if (builder != null) {
51 if (!suggestionsComputed) { 51 if (!suggestionsComputed) {
52 return builder.computeFull(request.node).then((bool result) { 52 bool result = await builder.computeFull(request.target.containingNode);
53 _updateSuggestions(request); 53 _updateSuggestions(request);
54 return result; 54 return result;
55 });
56 } 55 }
57 _updateSuggestions(request); 56 _updateSuggestions(request);
58 return new Future.value(true); 57 return true;
59 } 58 }
60 return new Future.value(false); 59 return false;
61 } 60 }
62 61
63 /** 62 /**
64 * If target is a function argument, suggest identifiers not invocations 63 * If target is a function argument, suggest identifiers not invocations
65 */ 64 */
66 void _updateSuggestions(DartCompletionRequest request) { 65 void _updateSuggestions(DartCompletionRequest request) {
67 if (request.target.isFunctionalArgument()) { 66 if (request.target.isFunctionalArgument()) {
68 request.convertInvocationsToIdentifiers(); 67 request.convertInvocationsToIdentifiers();
69 } 68 }
70 } 69 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 if (elem is ExecutableElement) { 150 if (elem is ExecutableElement) {
152 DartType returnType = elem.returnType; 151 DartType returnType = elem.returnType;
153 if (returnType != null && returnType.isVoid) { 152 if (returnType != null && returnType.isVoid) {
154 if (!optype.includeVoidReturnSuggestions) { 153 if (!optype.includeVoidReturnSuggestions) {
155 return; 154 return;
156 } 155 }
157 } 156 }
158 } 157 }
159 } 158 }
160 addSuggestion(elem, relevance: relevance); 159 addSuggestion(elem, relevance: relevance);
161 }; 160 }
161 ;
162 } 162 }
163 163
164 /** 164 /**
165 * Add suggestions which start with the given text. 165 * Add suggestions which start with the given text.
166 */ 166 */
167 _addFilteredSuggestions( 167 _addFilteredSuggestions(
168 String filterText, List<CompletionSuggestion> unfiltered) { 168 String filterText, List<CompletionSuggestion> unfiltered) {
169 //TODO (danrubel) Revisit this filtering once paged API has been added 169 //TODO (danrubel) Revisit this filtering once paged API has been added
170 unfiltered.forEach((CompletionSuggestion suggestion) { 170 unfiltered.forEach((CompletionSuggestion suggestion) {
171 if (filterText.length > 0) { 171 if (filterText.length > 0) {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions); 253 _addFilteredSuggestions(filterText, cache.libraryPrefixSuggestions);
254 } 254 }
255 if (optype.includeReturnValueSuggestions) { 255 if (optype.includeReturnValueSuggestions) {
256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions); 256 _addFilteredSuggestions(filterText, cache.otherImportedSuggestions);
257 } 257 }
258 if (optype.includeVoidReturnSuggestions) { 258 if (optype.includeVoidReturnSuggestions) {
259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions); 259 _addFilteredSuggestions(filterText, cache.importedVoidReturnSuggestions);
260 } 260 }
261 } 261 }
262 } 262 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698