Index: pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart |
diff --git a/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart b/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart |
index e105dfbe41ddba591d610215ba5f0a3d44e5d170..0cf5321893f5435d687a4b82bdf7f49c9b866ea6 100644 |
--- a/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart |
+++ b/pkg/analyzer_plugin/lib/utilities/fixes/fixes.dart |
@@ -5,13 +5,25 @@ |
import 'package:analyzer/dart/analysis/results.dart'; |
import 'package:analyzer/error/error.dart'; |
import 'package:analyzer/file_system/file_system.dart'; |
-import 'package:analyzer/src/generated/source.dart'; |
import 'package:analyzer_plugin/protocol/protocol.dart'; |
import 'package:analyzer_plugin/protocol/protocol_generated.dart'; |
import 'package:analyzer_plugin/src/utilities/fixes/fixes.dart'; |
import 'package:analyzer_plugin/utilities/generator.dart'; |
/** |
+ * The information about a requested set of fixes when computing fixes in a |
+ * `.dart` file. |
+ * |
+ * Clients may not extend, implement or mix-in this class. |
+ */ |
+abstract class DartFixesRequest implements FixesRequest { |
+ /** |
+ * The analysis result for the file in which the fixes are being requested. |
+ */ |
+ ResolveResult get result; |
+} |
+ |
+/** |
* An object that [FixContributor]s use to record fixes. |
* |
* Clients may not extend, implement or mix-in this class. |
@@ -33,7 +45,7 @@ abstract class FixContributor { |
* Contribute fixes for the location in the file specified by the given |
* [request] into the given [collector]. |
*/ |
- void computeFixes(FixesRequest request, FixCollector collector); |
+ void computeFixes(covariant FixesRequest request, FixCollector collector); |
} |
/** |
@@ -46,7 +58,7 @@ abstract class FixesRequest { |
* The analysis error to be fixed, or `null` if the error has not been |
* determined. |
*/ |
- AnalysisError get error; |
+ List<AnalysisError> get errorsToFix; |
/** |
* Return the offset within the source for which fixes are being requested. |
@@ -57,11 +69,6 @@ abstract class FixesRequest { |
* Return the resource provider associated with this request. |
*/ |
ResourceProvider get resourceProvider; |
- |
- /** |
- * The analysis result for the file in which the fixes are being requested. |
- */ |
- ResolveResult get result; |
} |
/** |
@@ -88,33 +95,16 @@ class FixGenerator { |
GeneratorResult generateFixesResponse(FixesRequest request) { |
List<Notification> notifications = <Notification>[]; |
FixCollectorImpl collector = new FixCollectorImpl(); |
- Iterable<AnalysisError> errors = _getErrors(request); |
- FixesRequestImpl requestImpl = request; |
for (FixContributor contributor in contributors) { |
try { |
- for (AnalysisError error in errors) { |
- requestImpl.error = error; |
- contributor.computeFixes(request, collector); |
- } |
+ contributor.computeFixes(request, collector); |
} catch (exception, stackTrace) { |
notifications.add(new PluginErrorParams( |
false, exception.toString(), stackTrace.toString()) |
.toNotification()); |
- } finally { |
- requestImpl.error = null; |
} |
} |
EditGetFixesResult result = new EditGetFixesResult(collector.fixes); |
return new GeneratorResult(result, notifications); |
} |
- |
- Iterable<AnalysisError> _getErrors(FixesRequest request) { |
- int offset = request.offset; |
- LineInfo lineInfo = request.result.lineInfo; |
- int offsetLine = lineInfo.getLocation(offset).lineNumber; |
- return request.result.errors.where((AnalysisError error) { |
- int errorLine = lineInfo.getLocation(error.offset).lineNumber; |
- return errorLine == offsetLine; |
- }); |
- } |
} |