| 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; | 5 library services.completion.computer; |
| 6 | 6 |
| 7 import 'dart:async'; | 7 import 'dart:async'; |
| 8 | 8 |
| 9 import 'package:analysis_services/completion/completion_suggestion.dart'; | 9 import 'package:analysis_services/completion/completion_suggestion.dart'; |
| 10 import 'package:analysis_services/search/search_engine.dart'; | 10 import 'package:analysis_services/search/search_engine.dart'; |
| 11 import 'package:analysis_services/src/completion/dart_completion_manager.dart'; | 11 import 'package:analysis_services/src/completion/dart_completion_manager.dart'; |
| 12 import 'package:analyzer/src/generated/ast.dart'; | 12 import 'package:analyzer/src/generated/ast.dart'; |
| 13 import 'package:analyzer/src/generated/engine.dart'; | 13 import 'package:analyzer/src/generated/engine.dart'; |
| 14 import 'package:analyzer/src/generated/source.dart'; | 14 import 'package:analyzer/src/generated/source.dart'; |
| 15 | 15 |
| 16 /** | 16 /** |
| 17 * The base class for computing code completion suggestions. | 17 * The base class for computing code completion suggestions. |
| 18 */ | 18 */ |
| 19 abstract class CompletionComputer { | 19 abstract class CompletionComputer { |
| 20 AnalysisContext context; | 20 AnalysisContext context; |
| 21 Source source; | 21 Source source; |
| 22 int offset; | 22 int offset; |
| 23 SearchEngine searchEngine; | 23 SearchEngine searchEngine; |
| 24 | 24 |
| 25 /** | 25 /** |
| 26 * Computes the initial set of [CompletionSuggestion]s based on information | 26 * Computes the initial set of [CompletionSuggestion]s based on |
| 27 * already cached in the analysis context. This method should execute | 27 * the compilation [unit], the AST [node] in which the completion occurred, |
| 28 * quickly and not block waiting for any analysis. | 28 * and information already cached in the analysis context. |
| 29 * The supplied [unit] and [node] may not be resolved. |
| 30 * This method should execute quickly and not block waiting for any analysis. |
| 29 * Returns `true` if the computer's work is complete | 31 * Returns `true` if the computer's work is complete |
| 30 * or `false` if [computeFull] should be called to complete the work. | 32 * or `false` if [computeFull] should be called to complete the work. |
| 31 */ | 33 */ |
| 32 bool computeFast(CompilationUnit unit, | 34 bool computeFast(CompilationUnit unit, AstNode node, |
| 33 List<CompletionSuggestion> suggestions); | 35 List<CompletionSuggestion> suggestions); |
| 34 | 36 |
| 35 /** | 37 /** |
| 36 * Computes [CompletionSuggestion]s for the specified position in the source. | 38 * Computes the complete set of [CompletionSuggestion]s based on |
| 39 * the resolved compilation [unit] and the resolved AST [node] in which the |
| 40 * completion occurred. |
| 37 * Returns `true` if the receiver modified the list of suggestions. | 41 * Returns `true` if the receiver modified the list of suggestions. |
| 38 */ | 42 */ |
| 39 Future<bool> computeFull(CompilationUnit unit, | 43 Future<bool> computeFull(CompilationUnit unit, AstNode node, |
| 40 List<CompletionSuggestion> suggestions); | 44 List<CompletionSuggestion> suggestions); |
| 41 } | 45 } |
| 42 | 46 |
| 43 /** | 47 /** |
| 44 * Manages `CompletionComputer`s for a given completion request. | 48 * Manages `CompletionComputer`s for a given completion request. |
| 45 */ | 49 */ |
| 46 abstract class CompletionManager { | 50 abstract class CompletionManager { |
| 47 | 51 |
| 48 StreamController<CompletionResult> controller; | 52 StreamController<CompletionResult> controller; |
| 49 | 53 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 final Source source; | 124 final Source source; |
| 121 final int offset; | 125 final int offset; |
| 122 | 126 |
| 123 NoOpCompletionManager(this.source, this.offset); | 127 NoOpCompletionManager(this.source, this.offset); |
| 124 | 128 |
| 125 @override | 129 @override |
| 126 void compute() { | 130 void compute() { |
| 127 controller.add(new CompletionResult(offset, 0, [], true)); | 131 controller.add(new CompletionResult(offset, 0, [], true)); |
| 128 } | 132 } |
| 129 } | 133 } |
| OLD | NEW |