| 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.computer.dart.toplevel; | 5 library services.completion.computer.dart.toplevel; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_server/src/protocol.dart' hide Element; | 9 import 'package:analysis_server/src/protocol.dart' hide Element; |
| 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; | 10 import 'package:analysis_server/src/services/completion/dart_completion_manager.
dart'; |
| 11 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; | 11 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; |
| 12 import 'package:analysis_server/src/services/search/search_engine.dart'; | 12 import 'package:analysis_server/src/services/search/search_engine.dart'; |
| 13 import 'package:analyzer/src/generated/ast.dart'; | 13 import 'package:analyzer/src/generated/ast.dart'; |
| 14 import 'package:analyzer/src/generated/element.dart'; | 14 import 'package:analyzer/src/generated/element.dart'; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * A computer for calculating imported class and top level variable | 17 * A computer for calculating imported class and top level variable |
| 18 * `completion.getSuggestions` request results. | 18 * `completion.getSuggestions` request results. |
| 19 */ | 19 */ |
| 20 class ImportedTypeComputer extends DartCompletionComputer { | 20 class ImportedComputer extends DartCompletionComputer { |
| 21 | 21 |
| 22 @override | 22 @override |
| 23 bool computeFast(DartCompletionRequest request) { | 23 bool computeFast(DartCompletionRequest request) { |
| 24 // TODO: implement computeFast | 24 // TODO: implement computeFast |
| 25 // - compute results based upon current search, then replace those results | 25 // - compute results based upon current search, then replace those results |
| 26 // during the full compute phase | 26 // during the full compute phase |
| 27 // - filter results based upon completion offset | 27 // - filter results based upon completion offset |
| 28 return false; | 28 return false; |
| 29 } | 29 } |
| 30 | 30 |
| 31 @override | 31 @override |
| 32 Future<bool> computeFull(DartCompletionRequest request) { | 32 Future<bool> computeFull(DartCompletionRequest request) { |
| 33 return request.node.accept(new _ImportedTypeVisitor(request)); | 33 return request.node.accept(new _ImportedVisitor(request)); |
| 34 } | 34 } |
| 35 } | 35 } |
| 36 | 36 |
| 37 /** | 37 /** |
| 38 * A visitor for determining which imported class and top level variable | 38 * A visitor for determining which imported class and top level variable |
| 39 * should be suggested and building those suggestions. | 39 * should be suggested and building those suggestions. |
| 40 */ | 40 */ |
| 41 class _ImportedTypeVisitor extends GeneralizingAstVisitor<Future<bool>> { | 41 class _ImportedVisitor extends GeneralizingAstVisitor<Future<bool>> { |
| 42 final DartCompletionRequest request; | 42 final DartCompletionRequest request; |
| 43 | 43 |
| 44 _ImportedTypeVisitor(this.request); | 44 _ImportedVisitor(this.request); |
| 45 | 45 |
| 46 @override | 46 @override |
| 47 Future<bool> visitCombinator(Combinator node) { | 47 Future<bool> visitCombinator(Combinator node) { |
| 48 NamespaceDirective directive = | 48 NamespaceDirective directive = |
| 49 node.getAncestor((parent) => parent is NamespaceDirective); | 49 node.getAncestor((parent) => parent is NamespaceDirective); |
| 50 if (directive != null) { | 50 if (directive != null) { |
| 51 LibraryElement library = directive.uriElement; | 51 LibraryElement library = directive.uriElement; |
| 52 LibraryElementSuggestionBuilder.suggestionsFor(request, library); | 52 LibraryElementSuggestionBuilder.suggestionsFor(request, library); |
| 53 return new Future.value(true); | 53 return new Future.value(true); |
| 54 } | 54 } |
| (...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 false)); | 139 false)); |
| 140 } | 140 } |
| 141 } | 141 } |
| 142 } | 142 } |
| 143 }); | 143 }); |
| 144 return true; | 144 return true; |
| 145 }); | 145 }); |
| 146 } | 146 } |
| 147 } | 147 } |
| 148 | 148 |
| OLD | NEW |