Version 2.16.0-42.0.dev
Merge commit 'b3e029ddc587875abc7f4232b40dee6e44e6674c' into 'dev'
diff --git a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
index ede2ade..2346ae1 100644
--- a/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
+++ b/pkg/analysis_server/lib/src/services/correction/bulk_fix_processor.dart
@@ -322,13 +322,15 @@
// apply it first.
var context = correctionContext(definingUnit, directivesOrderingError);
if (context != null) {
- await _applyProducer(context, OrganizeImports.newInstance());
+ await _generateFix(context, OrganizeImports.newInstance(),
+ directivesOrderingError.errorCode.name);
}
} else {
for (var error in unusedImportErrors) {
var context = correctionContext(definingUnit, error);
if (context != null) {
- await _applyProducer(context, RemoveUnusedImport.newInstance());
+ await _generateFix(context, RemoveUnusedImport.newInstance(),
+ error.errorCode.name);
}
}
}
@@ -357,23 +359,12 @@
return;
}
- int computeChangeHash() => (builder as ChangeBuilderImpl).changeHash;
-
- Future<void> generate(CorrectionProducer producer, String code) async {
- var oldHash = computeChangeHash();
- await _applyProducer(context, producer);
- var newHash = computeChangeHash();
- if (newHash != oldHash) {
- changeMap.add(result.path, code);
- }
- }
-
Future<void> bulkApply(
List<ProducerGenerator> generators, String codeName) async {
for (var generator in generators) {
var producer = generator();
if (producer.canBeAppliedInBulk) {
- await generate(producer, codeName);
+ await _generateFix(context, producer, codeName);
}
}
}
@@ -393,7 +384,7 @@
var multiProducer = multiGenerator();
multiProducer.configure(context);
for (var producer in multiProducer.producers) {
- await generate(producer, codeName);
+ await _generateFix(context, producer, codeName);
}
}
}
@@ -406,6 +397,18 @@
}
}
+ Future<void> _generateFix(CorrectionProducerContext context,
+ CorrectionProducer producer, String code) async {
+ int computeChangeHash() => (builder as ChangeBuilderImpl).changeHash;
+
+ var oldHash = computeChangeHash();
+ await _applyProducer(context, producer);
+ var newHash = computeChangeHash();
+ if (newHash != oldHash) {
+ changeMap.add(context.resolvedResult.path, code);
+ }
+ }
+
/// Return the override set corresponding to the given [result], or `null` if
/// there is no corresponding configuration file or the file content isn't a
/// valid override set.
diff --git a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
index 00f2730..44650b0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/fix_processor.dart
@@ -87,6 +87,9 @@
/// neither [assertHasFix] nor [assertHasFixAllFix] has been invoked.
late String resultCode;
+ /// The processor used to compute bulk fixes.
+ late BulkFixProcessor processor;
+
/// Return a list of the experiments that are to be enabled for tests in this
/// class, or `null` if there are no experiments that should be enabled.
List<String>? get experiments => null;
@@ -140,7 +143,7 @@
/// Returns the source change for computed fixes in the specified [testUnit].
Future<SourceChange> _computeSourceChange() async {
- var processor = await computeFixes();
+ processor = await computeFixes();
return processor.builder.sourceChange;
}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_import_test.dart
index c486e53..0dd8430 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unused_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unused_import_test.dart
@@ -5,6 +5,7 @@
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
+import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
import 'fix_processor.dart';
@@ -54,6 +55,11 @@
await assertHasFix('''
void f() {}
''');
+ var details = processor.fixDetails;
+ expect(details, hasLength(1));
+ var fixes = details[0].fixes;
+ expect(fixes, hasLength(1));
+ expect(fixes[0].occurrences, 3);
}
Future<void> test_usedAndUnused() async {
diff --git a/tools/VERSION b/tools/VERSION
index d12c805..188507e 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 16
PATCH 0
-PRERELEASE 41
+PRERELEASE 42
PRERELEASE_PATCH 0
\ No newline at end of file