| 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 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 370 typesToVisit.addAll(nextType.mixins); | 370 typesToVisit.addAll(nextType.mixins); |
| 371 } | 371 } |
| 372 return result; | 372 return result; |
| 373 } | 373 } |
| 374 | 374 |
| 375 /** | 375 /** |
| 376 * Add suggestions for the visible members in the given interface | 376 * Add suggestions for the visible members in the given interface |
| 377 */ | 377 */ |
| 378 static void suggestionsFor(DartCompletionRequest request, DartType type) { | 378 static void suggestionsFor(DartCompletionRequest request, DartType type) { |
| 379 CompilationUnit compilationUnit = | 379 CompilationUnit compilationUnit = |
| 380 request.node.getAncestor((AstNode node) => node is CompilationUnit); | 380 request.target.containingNode.getAncestor((n) => n is CompilationUnit); |
| 381 LibraryElement library = compilationUnit.element.library; | 381 LibraryElement library = compilationUnit.element.library; |
| 382 if (type is DynamicTypeImpl) { | 382 if (type is DynamicTypeImpl) { |
| 383 type = request.cache.objectClassElement.type; | 383 type = request.cache.objectClassElement.type; |
| 384 } | 384 } |
| 385 if (type is InterfaceType) { | 385 if (type is InterfaceType) { |
| 386 return new InterfaceTypeSuggestionBuilder(request)._buildSuggestions( | 386 return new InterfaceTypeSuggestionBuilder(request)._buildSuggestions( |
| 387 type, library); | 387 type, library); |
| 388 } | 388 } |
| 389 } | 389 } |
| 390 } | 390 } |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 435 addSuggestion(element); | 435 addSuggestion(element); |
| 436 } | 436 } |
| 437 } | 437 } |
| 438 | 438 |
| 439 /** | 439 /** |
| 440 * Add suggestions for the visible members in the given library | 440 * Add suggestions for the visible members in the given library |
| 441 */ | 441 */ |
| 442 static void suggestionsFor(DartCompletionRequest request, | 442 static void suggestionsFor(DartCompletionRequest request, |
| 443 CompletionSuggestionKind kind, LibraryElement library, bool typesOnly) { | 443 CompletionSuggestionKind kind, LibraryElement library, bool typesOnly) { |
| 444 if (library != null) { | 444 if (library != null) { |
| 445 library.visitChildren(new LibraryElementSuggestionBuilder(request, kind, t
ypesOnly)); | 445 library.visitChildren( |
| 446 new LibraryElementSuggestionBuilder(request, kind, typesOnly)); |
| 446 } | 447 } |
| 447 } | 448 } |
| 448 } | 449 } |
| 449 | 450 |
| 450 /** | 451 /** |
| 451 * This class visits elements in a class and provides suggestions based upon | 452 * This class visits elements in a class and provides suggestions based upon |
| 452 * the visible named constructors in that class. | 453 * the visible named constructors in that class. |
| 453 */ | 454 */ |
| 454 class NamedConstructorSuggestionBuilder extends GeneralizingElementVisitor | 455 class NamedConstructorSuggestionBuilder extends GeneralizingElementVisitor |
| 455 with ElementSuggestionBuilder implements SuggestionBuilder { | 456 with ElementSuggestionBuilder implements SuggestionBuilder { |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 * or `false` if [computeFull] should be called. | 578 * or `false` if [computeFull] should be called. |
| 578 */ | 579 */ |
| 579 bool computeFast(AstNode node); | 580 bool computeFast(AstNode node); |
| 580 | 581 |
| 581 /** | 582 /** |
| 582 * Return a future that computes the suggestions given a fully resolved AST. | 583 * Return a future that computes the suggestions given a fully resolved AST. |
| 583 * The future returns `true` if suggestions were added, else `false`. | 584 * The future returns `true` if suggestions were added, else `false`. |
| 584 */ | 585 */ |
| 585 Future<bool> computeFull(AstNode node); | 586 Future<bool> computeFull(AstNode node); |
| 586 } | 587 } |
| OLD | NEW |