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 418 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 return result; | 429 return result; |
430 } | 430 } |
431 | 431 |
432 /** | 432 /** |
433 * Add suggestions for the visible members in the given interface | 433 * Add suggestions for the visible members in the given interface |
434 */ | 434 */ |
435 static void suggestionsFor(DartCompletionRequest request, DartType type, | 435 static void suggestionsFor(DartCompletionRequest request, DartType type, |
436 {bool isSuper: false, String containingMethodName: null}) { | 436 {bool isSuper: false, String containingMethodName: null}) { |
437 CompilationUnit compilationUnit = | 437 CompilationUnit compilationUnit = |
438 request.target.containingNode.getAncestor((n) => n is CompilationUnit); | 438 request.target.containingNode.getAncestor((n) => n is CompilationUnit); |
439 LibraryElement library = compilationUnit.element.library; | 439 CompilationUnitElement unitElem = compilationUnit.element; |
| 440 if (unitElem == null) { |
| 441 return; |
| 442 } |
| 443 LibraryElement library = unitElem.library; |
440 if (type is DynamicTypeImpl) { | 444 if (type is DynamicTypeImpl) { |
441 type = request.cache.objectClassElement.type; | 445 type = request.cache.objectClassElement.type; |
442 } | 446 } |
443 if (type is InterfaceType) { | 447 if (type is InterfaceType) { |
444 return new InterfaceTypeSuggestionBuilder(request) | 448 new InterfaceTypeSuggestionBuilder(request) |
445 ._buildSuggestions(type, library, isSuper, containingMethodName); | 449 ._buildSuggestions(type, library, isSuper, containingMethodName); |
446 } | 450 } |
447 } | 451 } |
448 } | 452 } |
449 | 453 |
450 /** | 454 /** |
451 * This class visits elements in a library and provides suggestions based upon | 455 * This class visits elements in a library and provides suggestions based upon |
452 * the visible members in that library. Clients should call | 456 * the visible members in that library. Clients should call |
453 * [LibraryElementSuggestionBuilder.suggestionsFor]. | 457 * [LibraryElementSuggestionBuilder.suggestionsFor]. |
454 */ | 458 */ |
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
668 * or `false` if [computeFull] should be called. | 672 * or `false` if [computeFull] should be called. |
669 */ | 673 */ |
670 bool computeFast(AstNode node); | 674 bool computeFast(AstNode node); |
671 | 675 |
672 /** | 676 /** |
673 * Return a future that computes the suggestions given a fully resolved AST. | 677 * Return a future that computes the suggestions given a fully resolved AST. |
674 * The future returns `true` if suggestions were added, else `false`. | 678 * The future returns `true` if suggestions were added, else `false`. |
675 */ | 679 */ |
676 Future<bool> computeFull(AstNode node); | 680 Future<bool> computeFull(AstNode node); |
677 } | 681 } |
OLD | NEW |