| 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 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 173 * Return the request on which the builder is operating. | 173 * Return the request on which the builder is operating. |
| 174 */ | 174 */ |
| 175 DartCompletionRequest get request; | 175 DartCompletionRequest get request; |
| 176 | 176 |
| 177 /** | 177 /** |
| 178 * Add a suggestion based upon the given element. | 178 * Add a suggestion based upon the given element. |
| 179 */ | 179 */ |
| 180 void addSuggestion(Element element, {int relevance: DART_RELEVANCE_DEFAULT}) { | 180 void addSuggestion(Element element, {int relevance: DART_RELEVANCE_DEFAULT}) { |
| 181 if (element.isPrivate) { | 181 if (element.isPrivate) { |
| 182 LibraryElement elementLibrary = element.library; | 182 LibraryElement elementLibrary = element.library; |
| 183 LibraryElement unitLibrary = request.unit.element.library; | 183 CompilationUnitElement unitElem = request.unit.element; |
| 184 if (unitElem == null) { |
| 185 return; |
| 186 } |
| 187 LibraryElement unitLibrary = unitElem.library; |
| 184 if (elementLibrary != unitLibrary) { | 188 if (elementLibrary != unitLibrary) { |
| 185 return; | 189 return; |
| 186 } | 190 } |
| 187 } | 191 } |
| 188 if (element.isSynthetic) { | 192 if (element.isSynthetic) { |
| 189 if (element is PropertyAccessorElement || element is FieldElement) { | 193 if (element is PropertyAccessorElement || element is FieldElement) { |
| 190 return; | 194 return; |
| 191 } | 195 } |
| 192 } | 196 } |
| 193 String completion = element.displayName; | 197 String completion = element.displayName; |
| (...skipping 379 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 573 * or `false` if [computeFull] should be called. | 577 * or `false` if [computeFull] should be called. |
| 574 */ | 578 */ |
| 575 bool computeFast(AstNode node); | 579 bool computeFast(AstNode node); |
| 576 | 580 |
| 577 /** | 581 /** |
| 578 * Return a future that computes the suggestions given a fully resolved AST. | 582 * Return a future that computes the suggestions given a fully resolved AST. |
| 579 * The future returns `true` if suggestions were added, else `false`. | 583 * The future returns `true` if suggestions were added, else `false`. |
| 580 */ | 584 */ |
| 581 Future<bool> computeFull(AstNode node); | 585 Future<bool> computeFull(AstNode node); |
| 582 } | 586 } |
| OLD | NEW |