| 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 import 'dart:collection'; | 8 import 'dart:collection'; |
| 9 | 9 |
| 10 import 'package:analysis_server/src/protocol_server.dart' hide Element, | 10 import 'package:analysis_server/src/protocol_server.dart' hide Element, |
| 11 ElementKind; | 11 ElementKind; |
| 12 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; | 12 import 'package:analysis_server/src/services/completion/dart_completion_cache.da
rt'; |
| 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:analysis_server/src/services/completion/optype_ast_visitor.dart'
; | 14 import 'package:analysis_server/src/services/completion/optype.dart'; |
| 15 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; | 15 import 'package:analysis_server/src/services/completion/suggestion_builder.dart'
; |
| 16 import 'package:analyzer/src/generated/ast.dart'; | 16 import 'package:analyzer/src/generated/ast.dart'; |
| 17 import 'package:analyzer/src/generated/element.dart'; | 17 import 'package:analyzer/src/generated/element.dart'; |
| 18 | 18 |
| 19 /** | 19 /** |
| 20 * A computer for calculating imported class and top level variable | 20 * A computer for calculating imported class and top level variable |
| 21 * `completion.getSuggestions` request results. | 21 * `completion.getSuggestions` request results. |
| 22 */ | 22 */ |
| 23 class ImportedComputer extends DartCompletionComputer { | 23 class ImportedComputer extends DartCompletionComputer { |
| 24 bool shouldWaitForLowPrioritySuggestions; | 24 bool shouldWaitForLowPrioritySuggestions; |
| 25 _ImportedSuggestionBuilder builder; | 25 _ImportedSuggestionBuilder builder; |
| 26 | 26 |
| 27 ImportedComputer({this.shouldWaitForLowPrioritySuggestions: false}); | 27 ImportedComputer({this.shouldWaitForLowPrioritySuggestions: false}); |
| 28 | 28 |
| 29 @override | 29 @override |
| 30 bool computeFast(DartCompletionRequest request) { | 30 bool computeFast(DartCompletionRequest request) { |
| 31 | 31 OpType optype = request.optype; |
| 32 // Determine the type of suggestions to be made | 32 if (optype.includeTopLevelSuggestions) { |
| 33 OpTypeAstVisitor opTypeVisitor = new OpTypeAstVisitor(request.offset); | |
| 34 request.node.accept(opTypeVisitor); | |
| 35 | |
| 36 // Build the suggestions | |
| 37 if (opTypeVisitor.includeTopLevelSuggestions) { | |
| 38 builder = new _ImportedSuggestionBuilder( | 33 builder = new _ImportedSuggestionBuilder( |
| 39 request, | 34 request, |
| 40 typesOnly: opTypeVisitor.includeOnlyTypeNameSuggestions, | 35 typesOnly: optype.includeOnlyTypeNameSuggestions, |
| 41 excludeVoidReturn: !opTypeVisitor.includeVoidReturnSuggestions); | 36 excludeVoidReturn: !optype.includeVoidReturnSuggestions); |
| 42 builder.shouldWaitForLowPrioritySuggestions = | 37 builder.shouldWaitForLowPrioritySuggestions = |
| 43 shouldWaitForLowPrioritySuggestions; | 38 shouldWaitForLowPrioritySuggestions; |
| 44 return builder.computeFast(request.node); | 39 return builder.computeFast(request.node); |
| 45 } | 40 } |
| 46 return true; | 41 return true; |
| 47 } | 42 } |
| 48 | 43 |
| 49 @override | 44 @override |
| 50 Future<bool> computeFull(DartCompletionRequest request) { | 45 Future<bool> computeFull(DartCompletionRequest request) { |
| 51 if (builder != null) { | 46 if (builder != null) { |
| (...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 addFilteredSuggestions(cache.importedTypeSuggestions); | 191 addFilteredSuggestions(cache.importedTypeSuggestions); |
| 197 addFilteredSuggestions(cache.libraryPrefixSuggestions); | 192 addFilteredSuggestions(cache.libraryPrefixSuggestions); |
| 198 if (!typesOnly) { | 193 if (!typesOnly) { |
| 199 addFilteredSuggestions(cache.otherImportedSuggestions); | 194 addFilteredSuggestions(cache.otherImportedSuggestions); |
| 200 if (!excludeVoidReturn) { | 195 if (!excludeVoidReturn) { |
| 201 addFilteredSuggestions(cache.importedVoidReturnSuggestions); | 196 addFilteredSuggestions(cache.importedVoidReturnSuggestions); |
| 202 } | 197 } |
| 203 } | 198 } |
| 204 } | 199 } |
| 205 } | 200 } |
| OLD | NEW |