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

Unified Diff: pkg/analysis_server/lib/edit/fix/fix_dart.dart

Issue 1080653003: Create a public API for contributing fixes and make fixes pluggable (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Missed clean-up Created 5 years, 8 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/analysis_server/lib/edit/fix/fix_core.dart ('k') | pkg/analysis_server/lib/plugin/fix.dart » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: pkg/analysis_server/lib/edit/fix/fix_dart.dart
diff --git a/pkg/analysis_server/lib/edit/fix/fix_dart.dart b/pkg/analysis_server/lib/edit/fix/fix_dart.dart
new file mode 100644
index 0000000000000000000000000000000000000000..cfdd6b973403cf89b054200874dc1d753097caa4
--- /dev/null
+++ b/pkg/analysis_server/lib/edit/fix/fix_dart.dart
@@ -0,0 +1,41 @@
+// Copyright (c) 2015, 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.
+
+library analysis_server.edit.fix.fix_dart;
+
+import 'package:analysis_server/edit/fix/fix_core.dart';
+import 'package:analyzer/src/generated/ast.dart';
+import 'package:analyzer/src/generated/engine.dart';
+import 'package:analyzer/src/generated/error.dart';
+import 'package:analyzer/src/generated/source.dart';
+
+/**
+ * A [FixContributor] that can be used to contribute fixes for errors in Dart
+ * files.
+ */
+abstract class DartFixContributor extends FixContributor {
+ @override
+ List<Fix> computeFixes(AnalysisContext context, AnalysisError error) {
+ Source source = error.source;
+ if (!AnalysisEngine.isDartFileName(source.fullName)) {
+ return Fix.EMPTY_LIST;
+ }
+ List<Source> libraries = context.getLibrariesContaining(source);
+ if (libraries.isEmpty) {
+ return Fix.EMPTY_LIST;
+ }
+ CompilationUnit unit =
+ context.resolveCompilationUnit2(source, libraries[0]);
+ if (unit == null) {
+ return Fix.EMPTY_LIST;
+ }
+ return internalComputeFixes(unit, error);
+ }
+
+ /**
+ * Return a list of fixes for the given [error]. The error was reported
+ * against the given compilation [unit].
+ */
+ List<Fix> internalComputeFixes(CompilationUnit unit, AnalysisError error);
+}
« no previous file with comments | « pkg/analysis_server/lib/edit/fix/fix_core.dart ('k') | pkg/analysis_server/lib/plugin/fix.dart » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698