Chromium Code Reviews| Index: pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart |
| diff --git a/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart b/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart |
| index 54baa7c3d458a93d7112e9abe0c1a4bc92f1f90d..130a449f7701c79b7f1084ad378cc49c6c9ec63b 100644 |
| --- a/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart |
| +++ b/pkg/analysis_server/lib/plugin/edit/fix/fix_dart.dart |
| @@ -4,7 +4,11 @@ |
| library analysis_server.plugin.edit.fix.fix_dart; |
| +import 'dart:async'; |
| + |
| import 'package:analysis_server/plugin/edit/fix/fix_core.dart'; |
| +import 'package:analysis_server/src/services/correction/fix_internal.dart' |
| + show DartFixContextImpl; |
| import 'package:analyzer/file_system/file_system.dart'; |
| import 'package:analyzer/src/generated/ast.dart'; |
| import 'package:analyzer/src/generated/engine.dart'; |
| @@ -12,6 +16,33 @@ import 'package:analyzer/src/generated/error.dart'; |
| import 'package:analyzer/src/generated/source.dart'; |
| /** |
| + * An object used to provide context information for [DartFixContributor]s. |
| + * |
| + * Clients may not extend, implement or mix-in this class. |
| + */ |
| +abstract class DartFixContext { |
|
Brian Wilkerson
2015/11/20 22:11:59
Why not extend FixContext?
scheglov
2015/11/20 22:56:08
Done.
|
| + /** |
| + * The [AnalysisContext] to get fixes in. |
| + */ |
| + AnalysisContext get analysisContext; |
| + |
| + /** |
| + * The error to fix, should be reported in the given [analysisContext]. |
| + */ |
| + AnalysisError get error; |
| + |
| + /** |
| + * The [ResourceProvider] to access files and folders. |
| + */ |
| + ResourceProvider get resourceProvider; |
| + |
| + /** |
| + * The [CompilationUnit] to compute fixes in. |
| + */ |
| + CompilationUnit get unit; |
| +} |
| + |
| +/** |
| * A [FixContributor] that can be used to contribute fixes for errors in Dart |
| * files. |
| * |
| @@ -19,28 +50,27 @@ import 'package:analyzer/src/generated/source.dart'; |
| */ |
| abstract class DartFixContributor implements FixContributor { |
| @override |
| - List<Fix> computeFixes(ResourceProvider resourceProvider, |
| - AnalysisContext context, AnalysisError error) { |
| - Source source = error.source; |
| + Future<List<Fix>> computeFixes(FixContext context) async { |
| + AnalysisContext analysisContext = context.analysisContext; |
| + Source source = context.error.source; |
| if (!AnalysisEngine.isDartFileName(source.fullName)) { |
| return Fix.EMPTY_LIST; |
| } |
| - List<Source> libraries = context.getLibrariesContaining(source); |
| + List<Source> libraries = analysisContext.getLibrariesContaining(source); |
| if (libraries.isEmpty) { |
| return Fix.EMPTY_LIST; |
| } |
| CompilationUnit unit = |
| - context.resolveCompilationUnit2(source, libraries[0]); |
| + analysisContext.resolveCompilationUnit2(source, libraries[0]); |
| if (unit == null) { |
| return Fix.EMPTY_LIST; |
| } |
| - return internalComputeFixes(resourceProvider, unit, error); |
| + DartFixContext dartContext = new DartFixContextImpl(context, unit); |
| + return internalComputeFixes(dartContext); |
| } |
| /** |
| - * Return a list of fixes for the given [error]. The error was reported |
| - * against the given compilation [unit]. |
| + * Return a list of fixes for the given [context]. |
| */ |
| - List<Fix> internalComputeFixes(ResourceProvider resourceProvider, |
| - CompilationUnit unit, AnalysisError error); |
| + Future<List<Fix>> internalComputeFixes(DartFixContext context); |
| } |