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

Unified Diff: pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « pkg/analyzer_plugin/lib/plugin/fix_mixin.dart ('k') | pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
diff --git a/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart b/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
new file mode 100644
index 0000000000000000000000000000000000000000..8c95eac2a4cc15856b74aca4933d8b6ad329b8bf
--- /dev/null
+++ b/pkg/analyzer_plugin/lib/src/utilities/fixes/fixes.dart
@@ -0,0 +1,61 @@
+// Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+import 'package:analyzer/dart/analysis/results.dart';
+import 'package:analyzer/error/error.dart';
+import 'package:analyzer/file_system/file_system.dart';
+import 'package:analyzer_plugin/protocol/protocol_generated.dart';
+import 'package:analyzer_plugin/utilities/analyzer_converter.dart';
+import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+
+/**
+ * A concrete implementation of [FixCollector].
+ */
+class FixCollectorImpl implements FixCollector {
+ /**
+ * The list of fixes that have been collected.
+ */
+ final Map<AnalysisError, List<PrioritizedSourceChange>> fixMap =
+ <AnalysisError, List<PrioritizedSourceChange>>{};
+
+ /**
+ * Return the fixes that have been collected up to this point.
+ */
+ List<AnalysisErrorFixes> get fixes {
+ List<AnalysisErrorFixes> fixes = <AnalysisErrorFixes>[];
+ AnalyzerConverter converter = new AnalyzerConverter();
+ for (AnalysisError error in fixMap.keys) {
+ fixes.add(new AnalysisErrorFixes(converter.convertAnalysisError(error),
+ fixes: fixMap[error]));
+ }
+ return fixes;
+ }
+
+ @override
+ void addFix(AnalysisError error, PrioritizedSourceChange change) {
+ fixMap.putIfAbsent(error, () => <PrioritizedSourceChange>[]).add(change);
+ }
+}
+
+/**
+ * A concrete implementation of [FixesRequest].
+ */
+class FixesRequestImpl implements FixesRequest {
+ @override
+ AnalysisError error;
+
+ @override
+ final ResourceProvider resourceProvider;
+
+ @override
+ final int offset;
+
+ @override
+ final ResolveResult result;
+
+ /**
+ * Initialize a newly create request with the given data.
+ */
+ FixesRequestImpl(this.resourceProvider, this.offset, this.result);
+}
« no previous file with comments | « pkg/analyzer_plugin/lib/plugin/fix_mixin.dart ('k') | pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698