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

Side by Side Diff: pkg/analyzer_plugin/lib/plugin/fix_mixin.dart

Issue 2923283002: Add support for fixes (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 unified diff | Download patch
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 import 'dart:async';
6
7 import 'package:analyzer/dart/analysis/results.dart';
8 import 'package:analyzer/src/dart/analysis/driver.dart';
9 import 'package:analyzer_plugin/plugin/plugin.dart';
10 import 'package:analyzer_plugin/protocol/protocol.dart';
11 import 'package:analyzer_plugin/protocol/protocol_generated.dart';
12 import 'package:analyzer_plugin/src/utilities/fixes/fixes.dart';
13 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
14 import 'package:analyzer_plugin/utilities/generator.dart';
15
16 /**
17 * A mixin that can be used when creating a subclass of [ServerPlugin] to
18 * provide most of the implementation for handling fix requests.
19 *
20 * Clients may not extend or implement this class, but are allowed to use it as
21 * a mix-in when creating a subclass of [ServerPlugin].
22 */
23 abstract class FixesMixin implements ServerPlugin {
24 /**
25 * Return a list containing the fix contributors that should be used to create
26 * fixes when used in the context of the given analysis [driver].
27 */
28 List<FixContributor> getFixContributors(
29 covariant AnalysisDriverGeneric driver);
30
31 /**
32 * Return the result of using the given analysis [driver] to produce a fully
33 * resolved AST for the file with the given [path].
34 */
35 Future<ResolveResult> getResolveResultForFixes(
36 covariant AnalysisDriverGeneric driver, String path);
37
38 @override
39 Future<EditGetFixesResult> handleEditGetFixes(
40 EditGetFixesParams parameters) async {
41 String path = parameters.file;
42 ContextRoot contextRoot = contextRootContaining(path);
43 if (contextRoot == null) {
44 // Return an error from the request.
45 throw new RequestFailure(
46 RequestErrorFactory.pluginError('Failed to analyze $path', null));
47 }
48 AnalysisDriverGeneric driver = driverMap[contextRoot];
49 ResolveResult analysisResult = await getResolveResultForFixes(driver, path);
50 FixesRequestImpl request = new FixesRequestImpl(
51 resourceProvider, parameters.offset, analysisResult);
52 FixGenerator generator = new FixGenerator(getFixContributors(driver));
53 GeneratorResult result = await generator.generateFixesResponse(request);
54 result.sendNotifications(channel);
55 return result.result;
56 }
57 }
OLDNEW
« no previous file with comments | « no previous file | pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698