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

Side by Side Diff: pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart

Issue 2953093002: Update the plugin API (Closed)
Patch Set: Update FixesRequest Created 3 years, 5 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
OLDNEW
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file 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 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. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 import 'package:analyzer/dart/analysis/results.dart'; 5 import 'package:analyzer/dart/analysis/results.dart';
6 import 'package:analyzer/error/error.dart'; 6 import 'package:analyzer/error/error.dart';
7 import 'package:analyzer/file_system/file_system.dart'; 7 import 'package:analyzer/file_system/file_system.dart';
8 import 'package:analyzer_plugin/protocol/protocol_generated.dart'; 8 import 'package:analyzer_plugin/protocol/protocol_generated.dart';
9 import 'package:analyzer_plugin/utilities/analyzer_converter.dart'; 9 import 'package:analyzer_plugin/utilities/analyzer_converter.dart';
10 import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; 10 import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
11 11
12 /** 12 /**
13 * A concrete implementation of [DartFixesRequest].
14 */
15 class DartFixesRequestImpl implements DartFixesRequest {
16 @override
17 final ResourceProvider resourceProvider;
18
19 @override
20 final int offset;
21
22 @override
23 final List<AnalysisError> errorsToFix;
24
25 @override
26 final ResolveResult result;
27
28 /**
29 * Initialize a newly create request with the given data.
30 */
31 DartFixesRequestImpl(
32 this.resourceProvider, this.offset, this.errorsToFix, this.result);
33 }
34
35 /**
13 * A concrete implementation of [FixCollector]. 36 * A concrete implementation of [FixCollector].
14 */ 37 */
15 class FixCollectorImpl implements FixCollector { 38 class FixCollectorImpl implements FixCollector {
16 /** 39 /**
17 * The list of fixes that have been collected. 40 * The list of fixes that have been collected.
18 */ 41 */
19 final Map<AnalysisError, List<PrioritizedSourceChange>> fixMap = 42 final Map<AnalysisError, List<PrioritizedSourceChange>> fixMap =
20 <AnalysisError, List<PrioritizedSourceChange>>{}; 43 <AnalysisError, List<PrioritizedSourceChange>>{};
21 44
22 /** 45 /**
23 * Return the fixes that have been collected up to this point. 46 * Return the fixes that have been collected up to this point.
24 */ 47 */
25 List<AnalysisErrorFixes> get fixes { 48 List<AnalysisErrorFixes> get fixes {
26 List<AnalysisErrorFixes> fixes = <AnalysisErrorFixes>[]; 49 List<AnalysisErrorFixes> fixes = <AnalysisErrorFixes>[];
27 AnalyzerConverter converter = new AnalyzerConverter(); 50 AnalyzerConverter converter = new AnalyzerConverter();
28 for (AnalysisError error in fixMap.keys) { 51 for (AnalysisError error in fixMap.keys) {
29 fixes.add(new AnalysisErrorFixes(converter.convertAnalysisError(error), 52 fixes.add(new AnalysisErrorFixes(converter.convertAnalysisError(error),
30 fixes: fixMap[error])); 53 fixes: fixMap[error]));
31 } 54 }
32 return fixes; 55 return fixes;
33 } 56 }
34 57
35 @override 58 @override
36 void addFix(AnalysisError error, PrioritizedSourceChange change) { 59 void addFix(AnalysisError error, PrioritizedSourceChange change) {
37 fixMap.putIfAbsent(error, () => <PrioritizedSourceChange>[]).add(change); 60 fixMap.putIfAbsent(error, () => <PrioritizedSourceChange>[]).add(change);
38 } 61 }
39 } 62 }
40
41 /**
42 * A concrete implementation of [FixesRequest].
43 */
44 class FixesRequestImpl implements FixesRequest {
45 @override
46 AnalysisError error;
47
48 @override
49 final ResourceProvider resourceProvider;
50
51 @override
52 final int offset;
53
54 @override
55 final ResolveResult result;
56
57 /**
58 * Initialize a newly create request with the given data.
59 */
60 FixesRequestImpl(this.resourceProvider, this.offset, this.result);
61 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698