| 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:analyzer/src/generated/element.dart'; | 10 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; |
| 11 import 'package:analyzer/dart/element/element.dart'; |
| 12 import 'package:analyzer/dart/element/type.dart'; |
| 13 import 'package:analyzer/dart/element/visitor.dart'; |
| 11 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 12 import 'package:analyzer/src/generated/utilities_dart.dart'; | 15 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 13 import 'package:path/path.dart' as path; | 16 import 'package:path/path.dart' as path; |
| 14 import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
dart'; | |
| 15 | 17 |
| 16 const String DYNAMIC = 'dynamic'; | 18 const String DYNAMIC = 'dynamic'; |
| 17 | 19 |
| 18 /** | 20 /** |
| 19 * Return a suggestion based upon the given element | 21 * Return a suggestion based upon the given element |
| 20 * or `null` if a suggestion is not appropriate for the given element. | 22 * or `null` if a suggestion is not appropriate for the given element. |
| 21 * If the suggestion is not currently in scope, then specify | 23 * If the suggestion is not currently in scope, then specify |
| 22 * importForSource as the source to which an import should be added. | 24 * importForSource as the source to which an import should be added. |
| 23 */ | 25 */ |
| 24 CompletionSuggestion createSuggestion(Element element, | 26 CompletionSuggestion createSuggestion(Element element, |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 100 /** | 102 /** |
| 101 * Common mixin for sharing behavior | 103 * Common mixin for sharing behavior |
| 102 */ | 104 */ |
| 103 abstract class ElementSuggestionBuilder { | 105 abstract class ElementSuggestionBuilder { |
| 104 /** | 106 /** |
| 105 * A collection of completion suggestions. | 107 * A collection of completion suggestions. |
| 106 */ | 108 */ |
| 107 final List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; | 109 final List<CompletionSuggestion> suggestions = <CompletionSuggestion>[]; |
| 108 | 110 |
| 109 /** | 111 /** |
| 112 * Return the library in which the completion is requested. |
| 113 */ |
| 114 LibraryElement get containingLibrary; |
| 115 |
| 116 /** |
| 110 * Return the kind of suggestions that should be built. | 117 * Return the kind of suggestions that should be built. |
| 111 */ | 118 */ |
| 112 CompletionSuggestionKind get kind; | 119 CompletionSuggestionKind get kind; |
| 113 | 120 |
| 114 /** | 121 /** |
| 115 * Return the library in which the completion is requested. | |
| 116 */ | |
| 117 LibraryElement get containingLibrary; | |
| 118 | |
| 119 /** | |
| 120 * Add a suggestion based upon the given element. | 122 * Add a suggestion based upon the given element. |
| 121 */ | 123 */ |
| 122 void addSuggestion(Element element, | 124 void addSuggestion(Element element, |
| 123 {String prefix, int relevance: DART_RELEVANCE_DEFAULT}) { | 125 {String prefix, int relevance: DART_RELEVANCE_DEFAULT}) { |
| 124 if (element.isPrivate) { | 126 if (element.isPrivate) { |
| 125 if (element.library != containingLibrary) { | 127 if (element.library != containingLibrary) { |
| 126 return; | 128 return; |
| 127 } | 129 } |
| 128 } | 130 } |
| 129 if (prefix == null && element.isSynthetic) { | 131 if (prefix == null && element.isSynthetic) { |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 } | 233 } |
| 232 } | 234 } |
| 233 | 235 |
| 234 @override | 236 @override |
| 235 visitTopLevelVariableElement(TopLevelVariableElement element) { | 237 visitTopLevelVariableElement(TopLevelVariableElement element) { |
| 236 if (!typesOnly) { | 238 if (!typesOnly) { |
| 237 addSuggestion(element); | 239 addSuggestion(element); |
| 238 } | 240 } |
| 239 } | 241 } |
| 240 } | 242 } |
| OLD | NEW |