| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, 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.suggestion.builder; | 5 library services.completion.dart.suggestion.builder; |
| 6 | 6 |
| 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; | 7 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| 8 import 'package:analysis_server/src/protocol_server.dart' | 8 import 'package:analysis_server/src/protocol_server.dart' |
| 9 hide Element, ElementKind; | 9 hide Element, ElementKind; |
| 10 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | 10 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 * Return a suggestion based upon the given element | 22 * Return a suggestion based upon the given element |
| 23 * or `null` if a suggestion is not appropriate for the given element. | 23 * or `null` if a suggestion is not appropriate for the given element. |
| 24 * If the suggestion is not currently in scope, then specify | 24 * If the suggestion is not currently in scope, then specify |
| 25 * importForSource as the source to which an import should be added. | 25 * importForSource as the source to which an import should be added. |
| 26 */ | 26 */ |
| 27 CompletionSuggestion createSuggestion(Element element, | 27 CompletionSuggestion createSuggestion(Element element, |
| 28 {String completion, | 28 {String completion, |
| 29 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, | 29 CompletionSuggestionKind kind: CompletionSuggestionKind.INVOCATION, |
| 30 int relevance: DART_RELEVANCE_DEFAULT, | 30 int relevance: DART_RELEVANCE_DEFAULT, |
| 31 Source importForSource}) { | 31 Source importForSource}) { |
| 32 if (element == null) { |
| 33 return null; |
| 34 } |
| 32 if (element is ExecutableElement && element.isOperator) { | 35 if (element is ExecutableElement && element.isOperator) { |
| 33 // Do not include operators in suggestions | 36 // Do not include operators in suggestions |
| 34 return null; | 37 return null; |
| 35 } | 38 } |
| 36 if (completion == null) { | 39 if (completion == null) { |
| 37 completion = element.displayName; | 40 completion = element.displayName; |
| 38 } | 41 } |
| 39 bool isDeprecated = element.isDeprecated; | 42 bool isDeprecated = element.isDeprecated; |
| 40 CompletionSuggestion suggestion = new CompletionSuggestion( | 43 CompletionSuggestion suggestion = new CompletionSuggestion( |
| 41 kind, | 44 kind, |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 @override | 277 @override |
| 275 visitTopLevelVariableElement(TopLevelVariableElement element) { | 278 visitTopLevelVariableElement(TopLevelVariableElement element) { |
| 276 if (!typesOnly) { | 279 if (!typesOnly) { |
| 277 int relevance = element.library == containingLibrary | 280 int relevance = element.library == containingLibrary |
| 278 ? DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE | 281 ? DART_RELEVANCE_LOCAL_TOP_LEVEL_VARIABLE |
| 279 : DART_RELEVANCE_DEFAULT; | 282 : DART_RELEVANCE_DEFAULT; |
| 280 addSuggestion(element, relevance: relevance); | 283 addSuggestion(element, relevance: relevance); |
| 281 } | 284 } |
| 282 } | 285 } |
| 283 } | 286 } |
| OLD | NEW |