| 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.suggestion.builder; | 5 library services.completion.suggestion.builder; |
| 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' as protocol; | 10 import 'package:analysis_server/src/protocol_server.dart' as protocol; |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 CompletionSuggestionKind get kind; | 179 CompletionSuggestionKind get kind; |
| 180 | 180 |
| 181 /** | 181 /** |
| 182 * Return the request on which the builder is operating. | 182 * Return the request on which the builder is operating. |
| 183 */ | 183 */ |
| 184 DartCompletionRequest get request; | 184 DartCompletionRequest get request; |
| 185 | 185 |
| 186 /** | 186 /** |
| 187 * Add a suggestion based upon the given element. | 187 * Add a suggestion based upon the given element. |
| 188 */ | 188 */ |
| 189 void addSuggestion(Element element) { | 189 void addSuggestion(Element element, {int relevance: COMPLETION_RELEVANCE_DEFAU
LT}) { |
| 190 if (element.isPrivate) { | 190 if (element.isPrivate) { |
| 191 LibraryElement elementLibrary = element.library; | 191 LibraryElement elementLibrary = element.library; |
| 192 LibraryElement unitLibrary = request.unit.element.library; | 192 LibraryElement unitLibrary = request.unit.element.library; |
| 193 if (elementLibrary != unitLibrary) { | 193 if (elementLibrary != unitLibrary) { |
| 194 return; | 194 return; |
| 195 } | 195 } |
| 196 } | 196 } |
| 197 if (element.isSynthetic) { | 197 if (element.isSynthetic) { |
| 198 if (element is PropertyAccessorElement || element is FieldElement) { | 198 if (element is PropertyAccessorElement || element is FieldElement) { |
| 199 return; | 199 return; |
| 200 } | 200 } |
| 201 } | 201 } |
| 202 String completion = element.displayName; | 202 String completion = element.displayName; |
| 203 if (completion == null || | 203 if (completion == null || |
| 204 completion.length <= 0 || | 204 completion.length <= 0 || |
| 205 !_completions.add(completion)) { | 205 !_completions.add(completion)) { |
| 206 return; | 206 return; |
| 207 } | 207 } |
| 208 CompletionSuggestion suggestion = createSuggestion(element, kind: kind); | 208 CompletionSuggestion suggestion = createSuggestion(element, kind: kind, rele
vance: relevance); |
| 209 if (suggestion != null) { | 209 if (suggestion != null) { |
| 210 request.suggestions.add(suggestion); | 210 request.suggestions.add(suggestion); |
| 211 } | 211 } |
| 212 } | 212 } |
| 213 } | 213 } |
| 214 | 214 |
| 215 /** | 215 /** |
| 216 * This class provides suggestions based upon the visible instance members in | 216 * This class provides suggestions based upon the visible instance members in |
| 217 * an interface type. Clients should call | 217 * an interface type. Clients should call |
| 218 * [InterfaceTypeSuggestionBuilder.suggestionsFor]. | 218 * [InterfaceTypeSuggestionBuilder.suggestionsFor]. |
| (...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 * or `false` if [computeFull] should be called. | 573 * or `false` if [computeFull] should be called. |
| 574 */ | 574 */ |
| 575 bool computeFast(AstNode node); | 575 bool computeFast(AstNode node); |
| 576 | 576 |
| 577 /** | 577 /** |
| 578 * Return a future that computes the suggestions given a fully resolved AST. | 578 * Return a future that computes the suggestions given a fully resolved AST. |
| 579 * The future returns `true` if suggestions were added, else `false`. | 579 * The future returns `true` if suggestions were added, else `false`. |
| 580 */ | 580 */ |
| 581 Future<bool> computeFull(AstNode node); | 581 Future<bool> computeFull(AstNode node); |
| 582 } | 582 } |
| OLD | NEW |