| 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; |
| 11 import 'package:analysis_server/src/protocol_server.dart' | 11 import 'package:analysis_server/src/protocol_server.dart' |
| 12 hide Element, ElementKind; | 12 hide Element, ElementKind; |
| 13 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 13 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 14 import 'package:analyzer/src/generated/ast.dart'; | 14 import 'package:analyzer/src/generated/ast.dart'; |
| 15 import 'package:analyzer/src/generated/element.dart'; | 15 import 'package:analyzer/src/generated/element.dart'; |
| 16 import 'package:analyzer/src/generated/engine.dart' as engine; |
| 17 import 'package:analyzer/src/generated/source.dart'; |
| 16 import 'package:analyzer/src/generated/utilities_dart.dart'; | 18 import 'package:analyzer/src/generated/utilities_dart.dart'; |
| 17 import 'package:analyzer/src/generated/source.dart'; | |
| 18 import 'package:path/path.dart' as path; | 19 import 'package:path/path.dart' as path; |
| 19 | 20 |
| 20 const String DYNAMIC = 'dynamic'; | 21 const String DYNAMIC = 'dynamic'; |
| 21 | 22 |
| 22 /** | 23 /** |
| 23 * Return a suggestion based upon the given element | 24 * Return a suggestion based upon the given element |
| 24 * or `null` if a suggestion is not appropriate for the given element. | 25 * or `null` if a suggestion is not appropriate for the given element. |
| 25 * If the suggestion is not currently in scope, then specify | 26 * If the suggestion is not currently in scope, then specify |
| 26 * importForSource as the source to which an import should be added. | 27 * importForSource as the source to which an import should be added. |
| 27 */ | 28 */ |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 431 | 432 |
| 432 /** | 433 /** |
| 433 * Add suggestions for the visible members in the given interface | 434 * Add suggestions for the visible members in the given interface |
| 434 */ | 435 */ |
| 435 static void suggestionsFor(DartCompletionRequest request, DartType type, | 436 static void suggestionsFor(DartCompletionRequest request, DartType type, |
| 436 {bool isSuper: false, String containingMethodName: null}) { | 437 {bool isSuper: false, String containingMethodName: null}) { |
| 437 CompilationUnit compilationUnit = | 438 CompilationUnit compilationUnit = |
| 438 request.target.containingNode.getAncestor((n) => n is CompilationUnit); | 439 request.target.containingNode.getAncestor((n) => n is CompilationUnit); |
| 439 CompilationUnitElement unitElem = compilationUnit.element; | 440 CompilationUnitElement unitElem = compilationUnit.element; |
| 440 if (unitElem == null) { | 441 if (unitElem == null) { |
| 442 engine.AnalysisEngine.instance.logger |
| 443 .logInformation('Completion expected resolved AST'); |
| 441 return; | 444 return; |
| 442 } | 445 } |
| 443 LibraryElement library = unitElem.library; | 446 LibraryElement library = unitElem.library; |
| 444 if (type is DynamicTypeImpl) { | 447 if (type is DynamicTypeImpl) { |
| 445 type = request.cache.objectClassElement.type; | 448 type = request.cache.objectClassElement.type; |
| 446 } | 449 } |
| 447 if (type is InterfaceType) { | 450 if (type is InterfaceType) { |
| 448 new InterfaceTypeSuggestionBuilder(request) | 451 new InterfaceTypeSuggestionBuilder(request) |
| 449 ._buildSuggestions(type, library, isSuper, containingMethodName); | 452 ._buildSuggestions(type, library, isSuper, containingMethodName); |
| 450 } | 453 } |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 672 * or `false` if [computeFull] should be called. | 675 * or `false` if [computeFull] should be called. |
| 673 */ | 676 */ |
| 674 bool computeFast(AstNode node); | 677 bool computeFast(AstNode node); |
| 675 | 678 |
| 676 /** | 679 /** |
| 677 * Return a future that computes the suggestions given a fully resolved AST. | 680 * Return a future that computes the suggestions given a fully resolved AST. |
| 678 * The future returns `true` if suggestions were added, else `false`. | 681 * The future returns `true` if suggestions were added, else `false`. |
| 679 */ | 682 */ |
| 680 Future<bool> computeFull(AstNode node); | 683 Future<bool> computeFull(AstNode node); |
| 681 } | 684 } |
| OLD | NEW |