Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(123)

Unified Diff: pkg/analyzer_plugin/lib/plugin/completion_mixin.dart

Issue 2953093002: Update the plugin API (Closed)
Patch Set: Update FixesRequest Created 3 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_plugin/lib/plugin/assist_mixin.dart ('k') | pkg/analyzer_plugin/lib/plugin/fix_mixin.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+}
« no previous file with comments | « pkg/analyzer_plugin/lib/plugin/assist_mixin.dart ('k') | pkg/analyzer_plugin/lib/plugin/fix_mixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698