Chromium Code Reviews| 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 * Given the compilation unit and the node at the completion offset, |
| 27 * already cached in the analysis context. This method should execute | 27 * this computes the initial set of [CompletionSuggestion]s based on |
| 28 * quickly and not block waiting for any analysis. | 28 * information already cached in the analysis context. |
| 29 * This method should execute quickly and not block waiting for any analysis. | |
| 29 * Returns `true` if the computer's work is complete | 30 * Returns `true` if the computer's work is complete |
| 30 * or `false` if [computeFull] should be called to complete the work. | 31 * or `false` if [computeFull] should be called to complete the work. |
| 31 */ | 32 */ |
| 32 bool computeFast(CompilationUnit unit, | 33 bool computeFast(CompilationUnit unit, AstNode node, |
|
scheglov
2014/08/12 05:02:21
Would you please document [node]?
danrubel
2014/08/12 14:52:56
It is documented in the comment, but perhaps not c
| |
| 33 List<CompletionSuggestion> suggestions); | 34 List<CompletionSuggestion> suggestions); |
| 34 | 35 |
| 35 /** | 36 /** |
| 36 * Computes [CompletionSuggestion]s for the specified position in the source. | 37 * Given the resolved compilation unit and the node at the completion offset, |
| 37 * Returns `true` if the receiver modified the list of suggestions. | 38 * this computes [CompletionSuggestion]s for the specified position in the |
| 39 * source. Returns `true` if the receiver modified the list of suggestions. | |
| 38 */ | 40 */ |
| 39 Future<bool> computeFull(CompilationUnit unit, | 41 Future<bool> computeFull(CompilationUnit unit, AstNode node, |
| 40 List<CompletionSuggestion> suggestions); | 42 List<CompletionSuggestion> suggestions); |
| 41 } | 43 } |
| 42 | 44 |
| 43 /** | 45 /** |
| 44 * Manages `CompletionComputer`s for a given completion request. | 46 * Manages `CompletionComputer`s for a given completion request. |
| 45 */ | 47 */ |
| 46 abstract class CompletionManager { | 48 abstract class CompletionManager { |
| 47 | 49 |
| 48 StreamController<CompletionResult> controller; | 50 StreamController<CompletionResult> controller; |
| 49 | 51 |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 120 final Source source; | 122 final Source source; |
| 121 final int offset; | 123 final int offset; |
| 122 | 124 |
| 123 NoOpCompletionManager(this.source, this.offset); | 125 NoOpCompletionManager(this.source, this.offset); |
| 124 | 126 |
| 125 @override | 127 @override |
| 126 void compute() { | 128 void compute() { |
| 127 controller.add(new CompletionResult(offset, 0, [], true)); | 129 controller.add(new CompletionResult(offset, 0, [], true)); |
| 128 } | 130 } |
| 129 } | 131 } |
| OLD | NEW |