| Index: pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
|
| diff --git a/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart b/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
|
| index d4cbbeeb3fc678dd54b207fe17d98dc56c1147ce..813a6ace72aee546c7528b9b0a5525885ecffafc 100644
|
| --- a/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
|
| +++ b/pkg/analyzer_plugin/lib/plugin/completion_mixin.dart
|
| @@ -30,11 +30,12 @@ abstract class CompletionMixin implements ServerPlugin {
|
| covariant AnalysisDriverGeneric driver);
|
|
|
| /**
|
| - * Return the result of using the given analysis [driver] to produce a fully
|
| - * resolved AST for the file with the given [path].
|
| + * Return the completion request that should be passes to the contributors
|
| + * returned from [getCompletionContributors].
|
| */
|
| - Future<ResolveResult> getResolveResultForCompletion(
|
| - covariant AnalysisDriverGeneric driver, String path);
|
| + Future<CompletionRequest> getCompletionRequest(
|
| + CompletionGetSuggestionsParams parameters,
|
| + covariant AnalysisDriverGeneric driver);
|
|
|
| @override
|
| Future<CompletionGetSuggestionsResult> handleCompletionGetSuggestions(
|
| @@ -47,10 +48,7 @@ abstract class CompletionMixin implements ServerPlugin {
|
| RequestErrorFactory.pluginError('Failed to analyze $path', null));
|
| }
|
| AnalysisDriverGeneric driver = driverMap[contextRoot];
|
| - ResolveResult analysisResult =
|
| - await getResolveResultForCompletion(driver, path);
|
| - CompletionRequestImpl request = new CompletionRequestImpl(
|
| - resourceProvider, analysisResult, parameters.offset);
|
| + CompletionRequest request = await getCompletionRequest(parameters, driver);
|
| CompletionGenerator generator =
|
| new CompletionGenerator(getCompletionContributors(driver));
|
| GeneratorResult result =
|
| @@ -59,3 +57,24 @@ abstract class CompletionMixin implements ServerPlugin {
|
| return result.result;
|
| }
|
| }
|
| +
|
| +/**
|
| + * A mixin that can be used when creating a subclass of [ServerPlugin] and
|
| + * mixing in [CompletionMixin]. This implements the creation of the completion
|
| + * request based on the assumption that the driver being created is an
|
| + * [AnalysisDriver].
|
| + *
|
| + * Clients may not extend or implement this class, but are allowed to use it as
|
| + * a mix-in when creating a subclass of [ServerPlugin] that also uses
|
| + * [CompletionMixin] as a mix-in.
|
| + */
|
| +abstract class DartCompletionMixin implements CompletionMixin {
|
| + @override
|
| + Future<CompletionRequest> getCompletionRequest(
|
| + CompletionGetSuggestionsParams parameters,
|
| + covariant AnalysisDriver driver) async {
|
| + ResolveResult result = await driver.getResult(parameters.file);
|
| + return new DartCompletionRequestImpl(
|
| + resourceProvider, parameters.offset, result);
|
| + }
|
| +}
|
|
|