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

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

Issue 2953093002: Update the plugin API (Closed)
Patch Set: 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
Index: pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
diff --git a/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart b/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
index 692ac128ce955d2ce7f510597a63a5d3625541cb..adbf506aea9e59e8dd075c5bced4fbf51da68cc4 100644
--- a/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
+++ b/pkg/analyzer_plugin/lib/plugin/fix_mixin.dart
@@ -14,6 +14,25 @@ import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:analyzer_plugin/utilities/generator.dart';
/**
+ * A mixin that can be used when creating a subclass of [ServerPlugin] and
+ * mixing in [FixesMixin]. This implements the creation of the fixes 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
+ * [FixesMixin] as a mix-in.
+ */
+abstract class DartFixesMixin implements FixesMixin {
+ @override
+ Future<FixesRequest> getFixesRequest(
+ EditGetFixesParams parameters, covariant AnalysisDriver driver) async {
+ ResolveResult analysisResult = await driver.getResult(parameters.file);
+ return new FixesRequestImpl(
+ resourceProvider, parameters.offset, analysisResult);
+ }
+}
+
+/**
* A mixin that can be used when creating a subclass of [ServerPlugin] to
* provide most of the implementation for handling fix requests.
*
@@ -29,11 +48,11 @@ abstract class FixesMixin 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 fixes request that should be passes to the contributors
+ * returned from [getFixContributors].
*/
- Future<ResolveResult> getResolveResultForFixes(
- covariant AnalysisDriverGeneric driver, String path);
+ Future<FixesRequest> getFixesRequest(
+ EditGetFixesParams parameters, covariant AnalysisDriverGeneric driver);
@override
Future<EditGetFixesResult> handleEditGetFixes(
@@ -46,9 +65,7 @@ abstract class FixesMixin implements ServerPlugin {
RequestErrorFactory.pluginError('Failed to analyze $path', null));
}
AnalysisDriverGeneric driver = driverMap[contextRoot];
- ResolveResult analysisResult = await getResolveResultForFixes(driver, path);
- FixesRequestImpl request = new FixesRequestImpl(
- resourceProvider, parameters.offset, analysisResult);
+ FixesRequest request = await getFixesRequest(parameters, driver);
FixGenerator generator = new FixGenerator(getFixContributors(driver));
GeneratorResult result = await generator.generateFixesResponse(request);
result.sendNotifications(channel);

Powered by Google App Engine
This is Rietveld 408576698