Chromium Code Reviews| Index: pkg/analysis_server/lib/src/provisional/completion/completion_dart.dart |
| diff --git a/pkg/analysis_server/lib/src/provisional/completion/completion_dart.dart b/pkg/analysis_server/lib/src/provisional/completion/completion_dart.dart |
| index e52c4332423381b6259f6d7b01b9d6dddcf67038..cdcb8f25f359b11f2582990b0eb0d86fe21f1b18 100644 |
| --- a/pkg/analysis_server/lib/src/provisional/completion/completion_dart.dart |
| +++ b/pkg/analysis_server/lib/src/provisional/completion/completion_dart.dart |
| @@ -4,55 +4,24 @@ |
| library analysis_server.src.provisional.completion.completion_dart; |
| +import 'dart:async'; |
| + |
| import 'package:analysis_server/plugin/protocol/protocol.dart'; |
| import 'package:analysis_server/src/provisional/completion/completion_core.dart'; |
| import 'package:analysis_server/src/provisional/completion/dart/completion_target.dart'; |
| import 'package:analyzer/src/generated/ast.dart'; |
| -import 'package:analyzer/src/generated/engine.dart'; |
| -import 'package:analyzer/src/generated/source.dart'; |
| /** |
| - * An object used to produce completions for a specific error within a Dart |
| - * file. Completion contributors are long-lived objects and must not retain any |
| - * state between invocations of [computeSuggestions]. |
| + * An object used to produce completions at a specific location within a file. |
|
Brian Wilkerson
2015/11/22 18:02:46
"file" --> "Dart file"
danrubel
2015/11/23 17:47:31
Done.
|
| * |
| - * Clients may extend this class when implementing plugins. |
| + * Clients may implement this class when implementing plugins. |
| */ |
| -abstract class DartCompletionContributor implements CompletionContributor { |
| - @override |
| - List<CompletionSuggestion> computeSuggestions(CompletionRequest request) { |
| - if (request is DartCompletionRequest) { |
| - return internalComputeSuggestions(request); |
| - } |
| - AnalysisContext context = request.context; |
| - Source source = request.source; |
| - List<Source> libraries = context.getLibrariesContaining(source); |
| - if (libraries.length < 1) { |
| - return null; |
| - } |
| -// CompilationUnit unit = |
| -// context.getResolvedCompilationUnit2(source, libraries[0]); |
| -// bool isResolved = true; |
| -// if (unit == null) { |
| -// // TODO(brianwilkerson) Implement a method for getting a parsed |
| -// // compilation unit without parsing the unit if it hasn't been parsed. |
| -// unit = context.getParsedCompilationUnit(source); |
| -// if (unit == null) { |
| -// return null; |
| -// } |
| -// isResolved = false; |
| -// } |
| -// DartCompletionRequest dartRequest = |
| -// new DartCompletionRequestImpl(request, unit, isResolved); |
| -// return internalComputeSuggestions(dartRequest); |
| - return null; |
| - } |
| - |
| +abstract class DartCompletionContributor { |
| /** |
| - * Compute a list of completion suggestions based on the given completion |
| - * [request]. Return the suggestions that were computed. |
| + * Compute [suggestions] for the given completion [request]. |
|
scheglov
2015/11/22 05:19:01
Where is "suggestions" defined?
danrubel
2015/11/23 17:47:31
Revised similar to CompletionContributor.
|
| + * Return a [Future] that completes with a list of suggestions. |
| */ |
| - List<CompletionSuggestion> internalComputeSuggestions( |
| + Future<List<CompletionSuggestion>> computeSuggestions( |
| DartCompletionRequest request); |
| } |
| @@ -63,28 +32,16 @@ abstract class DartCompletionContributor implements CompletionContributor { |
| */ |
| abstract class DartCompletionRequest extends CompletionRequest { |
| /** |
| - * Return `true` if the compilation [unit] is resolved. |
| - */ |
| - bool get isResolved; |
| - |
| - /** |
| * Return the completion target. This determines what part of the parse tree |
| * will receive the newly inserted text. |
| */ |
| CompletionTarget get target; |
| /** |
| - * Cached information from a prior code completion operation. |
| - */ |
| - //DartCompletionCache get cache; |
| - |
| - /** |
| - * Return the compilation unit in which the completion was requested. |
| - */ |
| - CompilationUnit get unit; |
| - |
| - /** |
| - * Information about the types of suggestions that should be included. |
| + * Return a [Future] that completes with a compilation unit in which |
| + * all declarations in all scopes containing [target] have been resolved. |
| + * Any any information obtained from [target] prior to calling this method |
|
scheglov
2015/11/22 05:19:01
Really any! :-)
danrubel
2015/11/23 17:47:32
Fixed :)
|
| + * should be discarded as it may have changed. |
|
Brian Wilkerson
2015/11/22 18:02:46
Needs to document that `null` can be returned and
danrubel
2015/11/23 17:47:31
Done.
|
| */ |
| - //OpType get _optype; |
| + Future<CompilationUnit> resolveDeclarationsInScope(); |
| } |