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

Unified Diff: pkg/analyzer_plugin/lib/plugin/assist_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 | « no previous file | pkg/analyzer_plugin/lib/plugin/completion_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/assist_mixin.dart
diff --git a/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart b/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
index 5eb3e7a841e7a992d48c9b2f276ded67e691a083..1d26e9147a1662f193413b878e8f64f8d044d5f5 100644
--- a/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/assist_mixin.dart
@@ -29,11 +29,11 @@ abstract class AssistsMixin 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 assist request that should be passes to the contributors
+ * returned from [getAssistContributors].
*/
- Future<ResolveResult> getResolveResultForAssists(
- covariant AnalysisDriverGeneric driver, String path);
+ Future<AssistRequest> getAssistRequest(
+ EditGetAssistsParams parameters, covariant AnalysisDriverGeneric driver);
@override
Future<EditGetAssistsResult> handleEditGetAssists(
@@ -46,10 +46,7 @@ abstract class AssistsMixin implements ServerPlugin {
RequestErrorFactory.pluginError('Failed to analyze $path', null));
}
AnalysisDriverGeneric driver = driverMap[contextRoot];
- ResolveResult analysisResult =
- await getResolveResultForAssists(driver, path);
- AssistRequestImpl request = new AssistRequestImpl(
- resourceProvider, parameters.offset, parameters.length, analysisResult);
+ AssistRequest request = await getAssistRequest(parameters, driver);
AssistGenerator generator =
new AssistGenerator(getAssistContributors(driver));
GeneratorResult result = await generator.generateAssistsResponse(request);
@@ -57,3 +54,22 @@ abstract class AssistsMixin implements ServerPlugin {
return result.result;
}
}
+
+/**
+ * A mixin that can be used when creating a subclass of [ServerPlugin] and
+ * mixing in [AssistsMixin]. This implements the creation of the assists 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
+ * [AssistsMixin] as a mix-in.
+ */
+abstract class DartAssistsMixin implements AssistsMixin {
+ @override
+ Future<AssistRequest> getAssistRequest(
+ EditGetAssistsParams parameters, covariant AnalysisDriver driver) async {
+ ResolveResult result = await driver.getResult(parameters.file);
+ return new DartAssistRequestImpl(
+ resourceProvider, parameters.offset, parameters.length, result);
+ }
+}
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/plugin/completion_mixin.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698