| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |