disable legacy fix-all fix creation
Tests to be re-enabled when we wire-up `FixInFileProcessor`. (Or maybe we want a different approach to testing fix all fixes entirely? TBD.)
See: https://github.com/dart-lang/sdk/issues/45026
Change-Id: I66f83d06801a71143dcc770cc38d9e2f86782264
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/185180
Commit-Queue: Phil Quitslund <pquitslund@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
index c2753fe..cb7e610 100644
--- a/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
+++ b/pkg/analysis_server/lib/src/services/correction/fix_internal.dart
@@ -161,8 +161,6 @@
import 'package:analyzer/src/error/codes.dart';
import 'package:analyzer/src/generated/java_core.dart';
import 'package:analyzer/src/generated/parser.dart';
-import 'package:analyzer_plugin/protocol/protocol_common.dart'
- hide AnalysisError, Element, ElementKind;
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
import 'package:analyzer_plugin/utilities/change_builder/change_workspace.dart';
import 'package:analyzer_plugin/utilities/change_builder/conflicting_edit_exception.dart';
@@ -182,96 +180,13 @@
try {
var processor = FixProcessor(context);
var fixes = await processor.compute();
- var fixAllFixes = await _computeFixAllFixes(context, fixes);
- return List.from(fixes)..addAll(fixAllFixes);
+ // todo (pq): add fixes from FixInFileProcessor
+ // https://github.com/dart-lang/sdk/issues/45026
+ return fixes;
} on CancelCorrectionException {
return const <Fix>[];
}
}
-
- Future<List<Fix>> _computeFixAllFixes(
- DartFixContext context, List<Fix> fixes) async {
- final analysisError = context.error;
- final allAnalysisErrors = context.resolveResult.errors.toList();
-
- // Validate inputs:
- // - return if no fixes
- // - return if no other analysis errors
- if (fixes.isEmpty || allAnalysisErrors.length < 2) {
- return const <Fix>[];
- }
-
- // Remove any analysis errors that don't have the expected error code name
- allAnalysisErrors
- .removeWhere((e) => analysisError.errorCode.name != e.errorCode.name);
- if (allAnalysisErrors.length < 2) {
- return const <Fix>[];
- }
-
- // A map between each FixKind and the List of associated fixes
- var map = <FixKind, List<Fix>>{};
-
- // Populate the HashMap by looping through all AnalysisErrors, creating a
- // new FixProcessor to compute the other fixes that can be applied with this
- // one.
- // For each fix, put the fix into the HashMap.
- for (var i = 0; i < allAnalysisErrors.length; i++) {
- final FixContext fixContext = DartFixContextImpl(
- context.instrumentationService,
- context.workspace,
- context.resolveResult,
- allAnalysisErrors[i],
- (name) => [],
- );
- var processorI = FixProcessor(fixContext);
- var fixesListI = await processorI.compute();
- for (var f in fixesListI) {
- if (!map.containsKey(f.kind)) {
- map[f.kind] = <Fix>[]..add(f);
- } else {
- map[f.kind].add(f);
- }
- }
- }
-
- // For each FixKind in the HashMap, union each list together, then return
- // the set of unioned fixes.
- var result = <Fix>[];
- map.forEach((FixKind kind, List<Fix> fixesList) {
- if (fixesList.first.kind.canBeAppliedTogether()) {
- var unionFix = _unionFixList(fixesList);
- if (unionFix != null) {
- result.add(unionFix);
- }
- }
- });
- return result;
- }
-
- Fix _unionFixList(List<Fix> fixList) {
- if (fixList == null || fixList.isEmpty) {
- return null;
- } else if (fixList.length == 1) {
- return fixList[0];
- }
- var sourceChange = SourceChange(fixList[0].kind.appliedTogetherMessage);
- sourceChange.edits = List.from(fixList[0].change.edits);
- var edits = <SourceEdit>[];
- edits.addAll(fixList[0].change.edits[0].edits);
- sourceChange.linkedEditGroups =
- List.from(fixList[0].change.linkedEditGroups);
- for (var i = 1; i < fixList.length; i++) {
- edits.addAll(fixList[i].change.edits[0].edits);
- sourceChange.linkedEditGroups.addAll(fixList[i].change.linkedEditGroups);
- }
- // Sort the list of SourceEdits so that when the edits are applied, they
- // are applied from the end of the file to the top of the file.
- edits.sort((s1, s2) => s2.offset - s1.offset);
-
- sourceChange.edits[0].edits = edits;
-
- return Fix(fixList[0].kind, sourceChange);
- }
}
/// Computer for Dart "fix all in file" fixes.
diff --git a/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart b/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
index cdac70a..eadaf30 100644
--- a/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
+++ b/pkg/analysis_server/test/lsp/code_actions_fixes_test.dart
@@ -272,8 +272,6 @@
@override
String get testPackageLanguageVersion => latestLanguageVersion;
- /// todo (pq): prefer_is_empty newly produces fix-all-fixes; update this test appropriately
- @failingTest
Future<void> test_fixAll_notForAmbigiousProducers() async {
// The ReplaceWithIsEmpty producer does not provide a FixKind up-front, as
// it may produce `REPLACE_WITH_IS_EMPTY` or `REPLACE_WITH_IS_NOT_EMPTY`
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
index ebf1233..797f097 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_explicit_cast_test.dart
@@ -56,6 +56,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_assignment_general_all() async {
await resolveTestCode('''
f(A a) {
@@ -98,6 +99,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_assignment_list_all() async {
await resolveTestCode('''
f(List<A> a) {
@@ -140,6 +142,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_assignment_map_all() async {
await resolveTestCode('''
f(Map<A, B> a) {
@@ -186,6 +189,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_assignment_needsParens_all() async {
await resolveTestCode('''
f(A a) {
@@ -232,6 +236,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_assignment_set_all() async {
await resolveTestCode('''
f(Set<A> a) {
@@ -284,6 +289,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_declaration_general_all() async {
await resolveTestCode('''
f(A a) {
@@ -322,6 +328,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_declaration_list_all() async {
await resolveTestCode('''
f(List<A> a) {
@@ -360,6 +367,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_declaration_map_all() async {
await resolveTestCode('''
f(Map<A, B> a) {
@@ -402,6 +410,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_declaration_needsParens_all() async {
await resolveTestCode('''
f(A a) {
@@ -444,6 +453,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_declaration_set_all() async {
await resolveTestCode('''
f(Set<A> a) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart
index 95302e6..c7b5820 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_ne_null_test.dart
@@ -37,6 +37,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_nonBoolCondition_all() async {
await resolveTestCode('''
main(String p, String q) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart
index 09cfd74..14c84b6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_cast_test.dart
@@ -39,6 +39,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_assignment_all() async {
await resolveTestCode('''
main(Object p, Object q) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_parentheses_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_parentheses_test.dart
index 88b7f30..c8c9629 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_parentheses_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_parentheses_test.dart
@@ -23,6 +23,7 @@
@override
String get lintCode => LintNames.unnecessary_parenthesis;
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_all() async {
await resolveTestCode('''
void f() {
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 3fb232f..6a9cc3e 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
@@ -27,6 +27,7 @@
useLineEndingsForPlatform = false;
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_all_diverseImports() async {
await resolveTestCode('''
import 'dart:math';
@@ -41,6 +42,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_all_diverseImports2() async {
await resolveTestCode('''
import 'dart:async';
@@ -62,6 +64,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_all_singleLine() async {
await resolveTestCode('''
import 'dart:math'; import 'dart:math'; import 'dart:math';
@@ -111,6 +114,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_multipleOfSame_all() async {
await resolveTestCode('''
import 'dart:math';
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart
index 1e38a6f..0fa2fd0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_boolean_with_bool_test.dart
@@ -20,6 +20,7 @@
@override
FixKind get kind => DartFixKind.REPLACE_BOOLEAN_WITH_BOOL;
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_all() async {
await resolveTestCode('''
main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart
index 89ecb3f..9a6d0ed 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_eq_eq_null_test.dart
@@ -33,6 +33,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_isNull_all() async {
await resolveTestCode('''
main(p, q) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart
index a22c3f8..bf7e9db 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_not_eq_null_test.dart
@@ -33,6 +33,7 @@
''');
}
+ @FailingTest(issue: 'https://github.com/dart-lang/sdk/issues/45026')
Future<void> test_isNotNull_all() async {
await resolveTestCode('''
main(p, q) {