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

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

Issue 1076773002: do not suggest local functions (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
« no previous file with comments | « no previous file | pkg/analysis_server/test/mock_sdk.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.dart.cache; 5 library services.completion.dart.cache;
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 292 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 } 303 }
304 } 304 }
305 }); 305 });
306 } 306 }
307 307
308 /** 308 /**
309 * Add a suggestion for the given element. 309 * Add a suggestion for the given element.
310 */ 310 */
311 void _addSuggestion(Element element, int relevance) { 311 void _addSuggestion(Element element, int relevance) {
312 if (element is ExecutableElement) { 312 if (element is ExecutableElement) {
313 // Do not suggest operators or local functions
313 if (element.isOperator) { 314 if (element.isOperator) {
314 return; 315 return;
315 } 316 }
317 if (element is FunctionElement) {
318 if (element.enclosingElement is! CompilationUnitElement) {
319 return;
320 }
321 }
316 } 322 }
317 323
318 CompletionSuggestion suggestion = 324 CompletionSuggestion suggestion =
319 createSuggestion(element, relevance: relevance); 325 createSuggestion(element, relevance: relevance);
320 326
321 if (element is ExecutableElement) { 327 if (element is ExecutableElement) {
322 DartType returnType = element.returnType; 328 DartType returnType = element.returnType;
323 if (returnType != null && returnType.isVoid) { 329 if (returnType != null && returnType.isVoid) {
324 importedVoidReturnSuggestions.add(suggestion); 330 importedVoidReturnSuggestions.add(suggestion);
325 } else { 331 } else {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 @override 404 @override
399 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) { 405 void visitFunctionTypeAliasElement(FunctionTypeAliasElement element) {
400 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); 406 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT);
401 } 407 }
402 408
403 @override 409 @override
404 void visitTopLevelVariableElement(TopLevelVariableElement element) { 410 void visitTopLevelVariableElement(TopLevelVariableElement element) {
405 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT); 411 cache._addSuggestion(element, DART_RELEVANCE_DEFAULT);
406 } 412 }
407 } 413 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analysis_server/test/mock_sdk.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698