Version 2.14.0-265.0.dev
Merge commit '4160a6b361884914eb2bf74364b453d3c8be7b59' into 'dev'
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart
index a33a9b8..d6c2893 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_await_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
index 486e950..c3085d6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_const_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
index 5ed1d1d..f64cdf2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_diagnostic_property_reference_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart
index cc2d0c8..0d932ff 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_override_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
index 9708adb..3d633b0 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/add_required_test.dart
@@ -8,7 +8,6 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart
deleted file mode 100644
index 6edfd24..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor.dart
+++ /dev/null
@@ -1,92 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/correction/bulk_fix_processor.dart';
-import 'package:analysis_server/src/services/correction/change_workspace.dart';
-import 'package:analyzer/src/dart/analysis/byte_store.dart';
-import 'package:analyzer/src/services/available_declarations.dart';
-import 'package:analyzer_plugin/protocol/protocol_common.dart';
-import 'package:test/test.dart';
-
-import '../../../../../abstract_single_unit.dart';
-import '../../../../../utils/test_instrumentation_service.dart';
-
-/// A base class defining support for writing bulk fix processor tests.
-abstract class BulkFixProcessorTest extends AbstractSingleUnitTest {
- /// The source change associated with the fix that was found, or `null` if
- /// neither [assertHasFix] nor [assertHasFixAllFix] has been invoked.
- late SourceChange change;
-
- /// The result of applying the [change] to the file content, or `null` if
- /// neither [assertHasFix] nor [assertHasFixAllFix] has been invoked.
- late String resultCode;
-
- /// 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;
-
- /// Return the lint code being tested.
- String? get lintCode => null;
-
- /// Return `true` if this test uses config files.
- bool get useConfigFiles => false;
-
- /// The workspace in which fixes contributor operates.
- DartChangeWorkspace get workspace {
- return DartChangeWorkspace([session]);
- }
-
- Future<void> assertHasFix(String expected) async {
- change = await _computeSourceChange();
-
- // apply to "file"
- var fileEdits = change.edits;
- expect(fileEdits, hasLength(1));
-
- var fileContent = testCode;
- resultCode = SourceEdit.applySequence(fileContent, change.edits[0].edits);
- expect(resultCode, expected);
- }
-
- Future<void> assertNoFix() async {
- change = await _computeSourceChange();
- var fileEdits = change.edits;
- expect(fileEdits, isEmpty);
- }
-
- /// Computes fixes for the specified [testUnit].
- Future<BulkFixProcessor> computeFixes() async {
- var tracker = DeclarationsTracker(MemoryByteStore(), resourceProvider);
- var analysisContext = contextFor(testFile);
- tracker.addContext(analysisContext);
- var processor = BulkFixProcessor(TestInstrumentationService(), workspace,
- useConfigFiles: useConfigFiles);
- await processor.fixErrors([analysisContext]);
- return processor;
- }
-
- @override
- void setUp() {
- super.setUp();
- verifyNoTestUnitErrors = false;
- _createAnalysisOptionsFile();
- }
-
- /// Returns the source change for computed fixes in the specified [testUnit].
- Future<SourceChange> _computeSourceChange() async {
- var processor = await computeFixes();
- return processor.builder.sourceChange;
- }
-
- /// Create the analysis options file needed in order to correctly analyze the
- /// test file.
- void _createAnalysisOptionsFile() {
- var code = lintCode;
- if (code == null) {
- createAnalysisOptionsFile(experiments: experiments);
- } else {
- createAnalysisOptionsFile(experiments: experiments, lints: [code]);
- }
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_type_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_type_annotation_test.dart
deleted file mode 100644
index 600d12d..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_type_annotation_test.dart
+++ /dev/null
@@ -1,109 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveDynamicTypeAnnotationTest);
- defineReflectiveTests(RemoveSetterReturnTypeAnnotationTest);
- defineReflectiveTests(RemoveTypeAnnotationOnClosureParamsTest);
- defineReflectiveTests(TypeInitFormalsTest);
- });
-}
-
-@reflectiveTest
-class RemoveDynamicTypeAnnotationTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_annotating_with_dynamic;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-f(void foo(dynamic x)) {
- return null;
-}
-
-f2({dynamic defaultValue}) {
- return null;
-}
-''');
- await assertHasFix('''
-f(void foo(x)) {
- return null;
-}
-
-f2({defaultValue}) {
- return null;
-}
-''');
- }
-}
-
-@reflectiveTest
-class RemoveSetterReturnTypeAnnotationTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_return_types_on_setters;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void set s(int s) {}
-void set s2(int s2) {}
-''');
- await assertHasFix('''
-set s(int s) {}
-set s2(int s2) {}
-''');
- }
-}
-
-@reflectiveTest
-class RemoveTypeAnnotationOnClosureParamsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.avoid_types_on_closure_parameters;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-var x = ({Future<int> defaultValue}) => null;
-var y = (Future<int> defaultValue) => null;
-''');
- await assertHasFix('''
-var x = ({defaultValue}) => null;
-var y = (defaultValue) => null;
-''');
- }
-}
-
-@reflectiveTest
-class TypeInitFormalsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.type_init_formals;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class C {
- int f;
- C(int this.f);
-}
-
-class Point {
- int x, y;
- Point(int this.x, int this.y);
-}
-''');
- await assertHasFix('''
-class C {
- int f;
- C(this.f);
-}
-
-class Point {
- int x, y;
- Point(this.x, this.y);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_const_test.dart
deleted file mode 100644
index eb112f7..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_const_test.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveUnnecessaryConstTest);
- });
-}
-
-@reflectiveTest
-class RemoveUnnecessaryConstTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_const;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class C { const C(); }
-class D { const D(C c); }
-const c = const C();
-const list = const [];
-var d = const D(const C());
-''');
- await assertHasFix('''
-class C { const C(); }
-class D { const D(C c); }
-const c = C();
-const list = [];
-var d = const D(C());
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_new_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_new_test.dart
deleted file mode 100644
index 88670c3..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_new_test.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveUnnecessaryNewTest);
- });
-}
-
-@reflectiveTest
-class RemoveUnnecessaryNewTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_new;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-C f() => new C();
-
-class C {
- C();
-
- void m() {
- new C();
- }
-}
-''');
- await assertHasFix('''
-C f() => C();
-
-class C {
- C();
-
- void m() {
- C();
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_string_interpolation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_string_interpolation_test.dart
deleted file mode 100644
index 1ae3d1d..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/remove_unnecessary_string_interpolation_test.dart
+++ /dev/null
@@ -1,46 +0,0 @@
-// Copyright (c) 2021, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RemoveUnnecessaryStringInterpolation);
- });
-}
-
-@reflectiveTest
-class RemoveUnnecessaryStringInterpolation extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_string_interpolations;
-
- Future<void> test_embedded_removeBoth() async {
- await resolveTestCode(r'''
-void f(String s) {
- print('${'$s'}');
-}
-''');
- await assertHasFix(r'''
-void f(String s) {
- print(s);
-}
-''');
- }
-
- Future<void> test_embedded_removeOuter() async {
- await resolveTestCode(r'''
-void f(String s) {
- print('${'$s '}');
-}
-''');
- await assertHasFix(r'''
-void f(String s) {
- print('$s ');
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/rename_to_camel_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/rename_to_camel_case_test.dart
deleted file mode 100644
index 5248e32..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/rename_to_camel_case_test.dart
+++ /dev/null
@@ -1,45 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(RenameToCamelCaseTest);
- });
-}
-
-@reflectiveTest
-class RenameToCamelCaseTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.non_constant_identifier_names;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-main() {
- int my_integer_variable = 42;
- int foo;
- print(my_integer_variable);
- print(foo);
- [0, 1, 2].forEach((my_integer_variable) {
- print(my_integer_variable);
- });
-}
-''');
- await assertHasFix('''
-main() {
- int myIntegerVariable = 42;
- int foo;
- print(myIntegerVariable);
- print(foo);
- [0, 1, 2].forEach((myIntegerVariable) {
- print(myIntegerVariable);
- });
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_colon_with_equals_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_colon_with_equals_test.dart
deleted file mode 100644
index f057c74..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_colon_with_equals_test.dart
+++ /dev/null
@@ -1,37 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceColonWithEqualsTest);
- });
-}
-
-@reflectiveTest
-class ReplaceColonWithEqualsTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_equal_for_default_values;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f({int a: 1}) => null;
-
-class C {
- void m({int a: 1, int b: 2}) => null;
-}
-''');
- await assertHasFix('''
-void f({int a = 1}) => null;
-
-class C {
- void m({int a = 1, int b = 2}) => null;
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_final_with_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_final_with_const_test.dart
deleted file mode 100644
index d886f78..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_final_with_const_test.dart
+++ /dev/null
@@ -1,31 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceFinalWithConstTest);
- });
-}
-
-@reflectiveTest
-class ReplaceFinalWithConstTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_const_declarations;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-final int a = 1;
-final b = 1;
-''');
- await assertHasFix('''
-const int a = 1;
-const b = 1;
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_new_with_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_new_with_const_test.dart
deleted file mode 100644
index f8ba7bd..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_new_with_const_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceNewWithConstTest);
- });
-}
-
-@reflectiveTest
-class ReplaceNewWithConstTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_const_constructors;
-
- /// Disabled in BulkFixProcessor.
- @failingTest
- Future<void> test_singleFile() async {
- await resolveTestCode(r'''
-class C {
- const C();
-}
-main() {
- print('${new C()} ${new C()}');
-}
-''');
- await assertHasFix(r'''
-class C {
- const C();
-}
-main() {
- print('${const C()} ${const C()}');
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_null_with_closure_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_null_with_closure_test.dart
deleted file mode 100644
index 9a686bf..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_null_with_closure_test.dart
+++ /dev/null
@@ -1,41 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceNullWithClosureTest);
- });
-}
-
-@reflectiveTest
-class ReplaceNullWithClosureTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.null_closures;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f(List<int> l) {
- l.firstWhere((e) => e.isEven, orElse: null);
-}
-
-void f2(String s) {
- s.splitMapJoin('', onNonMatch: null);
-}
-''');
- await assertHasFix('''
-void f(List<int> l) {
- l.firstWhere((e) => e.isEven, orElse: () => null);
-}
-
-void f2(String s) {
- s.splitMapJoin('', onNonMatch: (String p1) => null);
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_conditional_assignment_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_conditional_assignment_test.dart
deleted file mode 100644
index 77c9615..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_conditional_assignment_test.dart
+++ /dev/null
@@ -1,50 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceWithConditionalAssignmentTest);
- });
-}
-
-@reflectiveTest
-class ReplaceWithConditionalAssignmentTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_conditional_assignment;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-class Person {
- String _fullName;
- void foo() {
- if (_fullName == null) {
- _fullName = getFullUserName(this);
- }
- }
- void bar() {
- if (_fullName == null)
- _fullName = getFullUserName(this);
- }
- String getFullUserName(Person p) => '';
-}
-''');
- await assertHasFix('''
-class Person {
- String _fullName;
- void foo() {
- _fullName ??= getFullUserName(this);
- }
- void bar() {
- _fullName ??= getFullUserName(this);
- }
- String getFullUserName(Person p) => '';
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_is_empty_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_is_empty_test.dart
deleted file mode 100644
index b61ffd7..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_is_empty_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceWithIsEmptyTest);
- });
-}
-
-@reflectiveTest
-class ReplaceWithIsEmptyTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_is_empty;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f(List c) {
- if (0 == c.length) {}
- if (1 > c.length) {}
-}
-''');
- await assertHasFix('''
-void f(List c) {
- if (c.isEmpty) {}
- if (c.isEmpty) {}
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_tear_off_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_tear_off_test.dart
deleted file mode 100644
index eef575b..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_tear_off_test.dart
+++ /dev/null
@@ -1,43 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceWithTearOffTest);
- });
-}
-
-@reflectiveTest
-class ReplaceWithTearOffTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.unnecessary_lambdas;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-Function f() => (name) {
- print(name);
-};
-
-void foo(){}
-Function f2() {
- return () {
- foo();
- };
-}
-''');
- await assertHasFix('''
-Function f() => print;
-
-void foo(){}
-Function f2() {
- return foo;
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_var_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_var_test.dart
deleted file mode 100644
index 27367dc..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/replace_with_var_test.dart
+++ /dev/null
@@ -1,47 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(ReplaceWithVarTest);
- });
-}
-
-@reflectiveTest
-class ReplaceWithVarTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.omit_local_variable_types;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-List f() {
- List<int> l = [];
- return l;
-}
-
-void f2(List<int> list) {
- for (int i in list) {
- print(i);
- }
-}
-''');
- await assertHasFix('''
-List f() {
- var l = <int>[];
- return l;
-}
-
-void f2(List<int> list) {
- for (var i in list) {
- print(i);
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart
deleted file mode 100644
index 3cc5338..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/sort_child_properties_last_test.dart
+++ /dev/null
@@ -1,64 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(SortChildPropertyLastTest);
- });
-}
-
-@reflectiveTest
-class SortChildPropertyLastTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.sort_child_properties_last;
-
- Future<void> test_singleFile() async {
- writeTestPackageConfig(flutter: true);
- await resolveTestCode('''
-import 'package:flutter/material.dart';
-main() {
- Column(
- children: [
- Column(
- children: [
- Text('a'),
- ],
- crossAxisAlignment: CrossAxisAlignment.center,
- ),
- Text('b'),
- Text('c'),
- Text('d'),
- ],
- crossAxisAlignment: CrossAxisAlignment.center,
- );
-}
-''');
- // todo (pq): two diagnostics are produced but only the first is fixed.
- // see: linter/test/rules/sort_child_properties_last.dart:nestedChildren()
- await assertHasFix('''
-import 'package:flutter/material.dart';
-main() {
- Column(
- crossAxisAlignment: CrossAxisAlignment.center,
- children: [
- Column(
- children: [
- Text('a'),
- ],
- crossAxisAlignment: CrossAxisAlignment.center,
- ),
- Text('b'),
- Text('c'),
- Text('d'),
- ],
- );
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
deleted file mode 100644
index 288509d..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/test_all.dart
+++ /dev/null
@@ -1,53 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor_test.dart' as bulk_fix_processor;
-import 'convert_to_is_not_test.dart' as convert_to_is_not;
-import 'data_driven_test.dart' as data_driven;
-import 'remove_type_annotation_test.dart' as remove_type_annotation;
-import 'remove_unnecessary_const_test.dart' as remove_unnecessary_const;
-import 'remove_unnecessary_new_test.dart' as remove_unnecessary_new;
-import 'remove_unnecessary_string_interpolation_test.dart'
- as remove_unnecessary_string_interpolation;
-import 'rename_to_camel_case_test.dart' as rename_to_camel_case;
-import 'replace_colon_with_equals_test.dart' as replace_colon_with_equals;
-import 'replace_final_with_const_test.dart' as replace_final_with_const;
-import 'replace_new_with_const_test.dart' as replace_new_with_const;
-import 'replace_null_with_closure_test.dart' as replace_null_with_closure;
-import 'replace_with_conditional_assignment_test.dart'
- as replace_with_conditional_assignment;
-import 'replace_with_is_empty_test.dart' as replace_with_is_empty;
-import 'replace_with_tear_off_test.dart' as replace_with_tear_off;
-import 'replace_with_var_test.dart' as replace_with_var;
-import 'sort_child_properties_last_test.dart' as sort_child_properties_last;
-import 'use_curly_braces_test.dart' as use_curly_braces;
-import 'use_is_not_empty_test.dart' as use_is_not_empty;
-import 'use_rethrow_test.dart' as use_rethrow;
-
-void main() {
- defineReflectiveSuite(() {
- bulk_fix_processor.main();
- convert_to_is_not.main();
- data_driven.main();
- remove_type_annotation.main();
- remove_unnecessary_const.main();
- remove_unnecessary_new.main();
- remove_unnecessary_string_interpolation.main();
- rename_to_camel_case.main();
- replace_with_conditional_assignment.main();
- replace_colon_with_equals.main();
- replace_final_with_const.main();
- replace_new_with_const.main();
- replace_null_with_closure.main();
- replace_with_is_empty.main();
- replace_with_tear_off.main();
- replace_with_var.main();
- sort_child_properties_last.main();
- use_curly_braces.main();
- use_is_not_empty.main();
- use_rethrow.main();
- }, name: 'bulk');
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/use_is_not_empty_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/use_is_not_empty_test.dart
deleted file mode 100644
index 1f337b8..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/use_is_not_empty_test.dart
+++ /dev/null
@@ -1,35 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(UseIsNotEmptyTest);
- });
-}
-
-@reflectiveTest
-class UseIsNotEmptyTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.prefer_is_not_empty;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f(List<int> l) {
- if (!l.isEmpty) {}
- if (!l.isEmpty || true) {}
-}
-''');
- await assertHasFix('''
-void f(List<int> l) {
- if (l.isNotEmpty) {}
- if (l.isNotEmpty || true) {}
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/use_rethrow_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk/use_rethrow_test.dart
deleted file mode 100644
index 9d4678b..0000000
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/use_rethrow_test.dart
+++ /dev/null
@@ -1,51 +0,0 @@
-// Copyright (c) 2020, 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.
-
-import 'package:analysis_server/src/services/linter/lint_names.dart';
-import 'package:test_reflective_loader/test_reflective_loader.dart';
-
-import 'bulk_fix_processor.dart';
-
-void main() {
- defineReflectiveSuite(() {
- defineReflectiveTests(UseRethrowTest);
- });
-}
-
-@reflectiveTest
-class UseRethrowTest extends BulkFixProcessorTest {
- @override
- String get lintCode => LintNames.use_rethrow_when_possible;
-
- Future<void> test_singleFile() async {
- await resolveTestCode('''
-void f() {
- try {} catch (e) {
- throw e;
- }
-}
-
-void f2() {
- try {} catch (e, stackTrace) {
- print(stackTrace);
- throw e;
- }
-}
-''');
- await assertHasFix('''
-void f() {
- try {} catch (e) {
- rethrow;
- }
-}
-
-void f2() {
- try {} catch (e, stackTrace) {
- print(stackTrace);
- rethrow;
- }
-}
-''');
- }
-}
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor_test.dart b/pkg/analysis_server/test/src/services/correction/fix/bulk_fix_processor_test.dart
similarity index 97%
rename from pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor_test.dart
rename to pkg/analysis_server/test/src/services/correction/fix/bulk_fix_processor_test.dart
index 09b2da5..b5c721f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/bulk_fix_processor_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/bulk_fix_processor_test.dart
@@ -6,7 +6,7 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk_fix_processor.dart';
+import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart
index 6f68f20..92308b5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_documentation_into_line_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart
index 84d4285..88ac31a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_for_each_to_for_loop_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_into_is_not_test.dart
similarity index 95%
rename from pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart
rename to pkg/analysis_server/test/src/services/correction/fix/convert_into_is_not_test.dart
index f83a3b9..a49f151 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/convert_to_is_not_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_into_is_not_test.dart
@@ -5,7 +5,7 @@
import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk_fix_processor.dart';
+import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart
index 9796fa4..d0e335b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_contains_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart
index a083583..b395b2a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_for_element_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart
index 7279ed8..d904bf6 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_generic_function_syntax_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart
index ca70353..74c7b8c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_element_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart
index c395555..94cd67f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_if_null_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart
index 3be5cf8..2df3929 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_int_literal_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart
index 938fe3e..a74a556 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_list_literal_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart
index f5ca86a..f29794a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_map_literal_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart
index d5e10ac..e99892a 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_null_aware_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
index aaf2cf6..e4952f3 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_package_import_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart
index 0b20f39..260d20f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_relative_import_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart
index 37e97ef..b0fdf66 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_set_literal_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart
index 889b22a..42e0f6e 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_single_quoted_string_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart
index db6fbce..497caf3 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_spread_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart b/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart
index 0dc4ebe..6876af9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/convert_to_where_type_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart b/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
index 24e8030..185784b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/create_method_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart
similarity index 99%
rename from pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart
rename to pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart
index cbe56ed..e2c4988 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/data_driven_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/data_driven_test.dart
@@ -10,7 +10,7 @@
import 'package:test/test.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk_fix_processor.dart';
+import '../fix_processor.dart';
void main() {
defineReflectiveSuite(() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/data_driven/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/data_driven/test_all.dart
index a21ba3c..64cffa2 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/data_driven/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/data_driven/test_all.dart
@@ -7,6 +7,7 @@
import 'add_type_parameter_test.dart' as add_type_parameter;
import 'code_fragment_parser_test.dart' as code_fragment_parser;
import 'code_template_test.dart' as code_template;
+import 'data_driven_test.dart' as data_driven;
import 'diagnostics/test_all.dart' as diagnostics;
import 'element_matcher_test.dart' as element_matcher;
import 'end_to_end_test.dart' as end_to_end;
@@ -25,6 +26,7 @@
add_type_parameter.main();
code_fragment_parser.main();
code_template.main();
+ data_driven.main();
diagnostics.main();
element_matcher.main();
end_to_end.main();
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 0d952a4..366f8d1 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
@@ -4,6 +4,7 @@
import 'package:analysis_server/plugin/edit/fix/fix_core.dart';
import 'package:analysis_server/src/services/completion/dart/extension_cache.dart';
+import 'package:analysis_server/src/services/correction/bulk_fix_processor.dart';
import 'package:analysis_server/src/services/correction/change_workspace.dart';
import 'package:analysis_server/src/services/correction/fix.dart';
import 'package:analysis_server/src/services/correction/fix/dart/top_level_declarations.dart';
@@ -76,6 +77,85 @@
}
}
+/// A base class defining support for writing bulk fix processor tests.
+abstract class BulkFixProcessorTest extends AbstractSingleUnitTest {
+ /// The source change associated with the fix that was found, or `null` if
+ /// neither [assertHasFix] nor [assertHasFixAllFix] has been invoked.
+ late SourceChange change;
+
+ /// The result of applying the [change] to the file content, or `null` if
+ /// neither [assertHasFix] nor [assertHasFixAllFix] has been invoked.
+ late String resultCode;
+
+ /// 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;
+
+ /// Return the lint code being tested.
+ String? get lintCode => null;
+
+ /// Return `true` if this test uses config files.
+ bool get useConfigFiles => false;
+
+ /// The workspace in which fixes contributor operates.
+ DartChangeWorkspace get workspace {
+ return DartChangeWorkspace([session]);
+ }
+
+ Future<void> assertHasFix(String expected) async {
+ change = await _computeSourceChange();
+
+ // apply to "file"
+ var fileEdits = change.edits;
+ expect(fileEdits, hasLength(1));
+
+ var fileContent = testCode;
+ resultCode = SourceEdit.applySequence(fileContent, change.edits[0].edits);
+ expect(resultCode, expected);
+ }
+
+ Future<void> assertNoFix() async {
+ change = await _computeSourceChange();
+ var fileEdits = change.edits;
+ expect(fileEdits, isEmpty);
+ }
+
+ /// Computes fixes for the specified [testUnit].
+ Future<BulkFixProcessor> computeFixes() async {
+ var tracker = DeclarationsTracker(MemoryByteStore(), resourceProvider);
+ var analysisContext = contextFor(testFile);
+ tracker.addContext(analysisContext);
+ var processor = BulkFixProcessor(TestInstrumentationService(), workspace,
+ useConfigFiles: useConfigFiles);
+ await processor.fixErrors([analysisContext]);
+ return processor;
+ }
+
+ @override
+ void setUp() {
+ super.setUp();
+ verifyNoTestUnitErrors = false;
+ _createAnalysisOptionsFile();
+ }
+
+ /// Returns the source change for computed fixes in the specified [testUnit].
+ Future<SourceChange> _computeSourceChange() async {
+ var processor = await computeFixes();
+ return processor.builder.sourceChange;
+ }
+
+ /// Create the analysis options file needed in order to correctly analyze the
+ /// test file.
+ void _createAnalysisOptionsFile() {
+ var code = lintCode;
+ if (code == null) {
+ createAnalysisOptionsFile(experiments: experiments);
+ } else {
+ createAnalysisOptionsFile(experiments: experiments, lints: [code]);
+ }
+ }
+}
+
/// A base class defining support for writing fix-in-file processor tests.
abstract class FixInFileProcessorTest extends BaseFixProcessorTest {
void assertProduces(Fix fix, String expected) {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart
index b9da3df..5ac3483 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/inline_invocation_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart b/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
index 3ee2db1..f9f661b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/inline_typedef_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart b/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
index 83c4c70..d9e883f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/make_final_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
index 51a36e8..736da8c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_argument_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart
index 67c0552..33e28a9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_await_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart
index 37a0e90..1938e20 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_duplicate_case_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart
index ddc26fe..1e5bf88 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_catch_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart
index 477e58e..344cd5f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_constructor_body_test.dart
@@ -8,7 +8,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart
index 7302532..4466f80 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_else_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart
index b66d6ce..b8c514f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_empty_statement_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
index e73f4f7..e210ebc 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_if_null_operator_test.dart
@@ -8,7 +8,6 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart
index c28a1f8..573a033 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_initializer_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
index 73128de..646d310 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_interpolation_braces_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
index 3c2a19e..33821d3 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_method_declaration_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
index cbbd31a..ee3e204 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_non_null_assertion_test.dart
@@ -7,7 +7,6 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart
index 4d35f93..56ce445 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_operator_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
index 3668822..20ee77f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_question_mark_test.dart
@@ -8,7 +8,6 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_returned_value_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_returned_value_test.dart
index 41d65eb..70aa710 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_returned_value_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_returned_value_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart
index 626c668..2f6d984 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_this_expression_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_type_annotation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_type_annotation_test.dart
index 31af358..f92c463 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_type_annotation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_type_annotation_test.dart
@@ -11,14 +11,45 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(AvoidAnnotatingWithDynamicBulkTest);
defineReflectiveTests(AvoidAnnotatingWithDynamicTest);
+ defineReflectiveTests(AvoidReturnTypesOnSettersBulkTest);
defineReflectiveTests(AvoidReturnTypesOnSettersTest);
+ defineReflectiveTests(AvoidTypesOnClosureParametersBulkTest);
defineReflectiveTests(AvoidTypesOnClosureParametersTest);
+ defineReflectiveTests(TypeInitFormalsBulkTest);
defineReflectiveTests(TypeInitFormalsTest);
});
}
@reflectiveTest
+class AvoidAnnotatingWithDynamicBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_annotating_with_dynamic;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+f(void foo(dynamic x)) {
+ return null;
+}
+
+f2({dynamic defaultValue}) {
+ return null;
+}
+''');
+ await assertHasFix('''
+f(void foo(x)) {
+ return null;
+}
+
+f2({defaultValue}) {
+ return null;
+}
+''');
+ }
+}
+
+@reflectiveTest
class AvoidAnnotatingWithDynamicTest extends RemoveTypeAnnotationTest {
@override
String get lintCode => LintNames.avoid_annotating_with_dynamic;
@@ -77,6 +108,23 @@
}
@reflectiveTest
+class AvoidReturnTypesOnSettersBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_return_types_on_setters;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void set s(int s) {}
+void set s2(int s2) {}
+''');
+ await assertHasFix('''
+set s(int s) {}
+set s2(int s2) {}
+''');
+ }
+}
+
+@reflectiveTest
class AvoidReturnTypesOnSettersTest extends RemoveTypeAnnotationTest {
@override
String get lintCode => LintNames.avoid_return_types_on_setters;
@@ -92,6 +140,23 @@
}
@reflectiveTest
+class AvoidTypesOnClosureParametersBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.avoid_types_on_closure_parameters;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+var x = ({Future<int> defaultValue}) => null;
+var y = (Future<int> defaultValue) => null;
+''');
+ await assertHasFix('''
+var x = ({defaultValue}) => null;
+var y = (defaultValue) => null;
+''');
+ }
+}
+
+@reflectiveTest
class AvoidTypesOnClosureParametersTest extends RemoveTypeAnnotationTest {
@override
String get lintCode => LintNames.avoid_types_on_closure_parameters;
@@ -131,6 +196,37 @@
}
@reflectiveTest
+class TypeInitFormalsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.type_init_formals;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class C {
+ int f;
+ C(int this.f);
+}
+
+class Point {
+ int x, y;
+ Point(int this.x, int this.y);
+}
+''');
+ await assertHasFix('''
+class C {
+ int f;
+ C(this.f);
+}
+
+class Point {
+ int x, y;
+ Point(this.x, this.y);
+}
+''');
+ }
+}
+
+@reflectiveTest
class TypeInitFormalsTest extends RemoveTypeAnnotationTest {
@override
String get lintCode => LintNames.type_init_formals;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_const_test.dart
index 1f1e6f2..4444165 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_const_test.dart
@@ -11,11 +11,35 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveUnnecessaryConstBulkTest);
defineReflectiveTests(RemoveUnnecessaryConstTest);
});
}
@reflectiveTest
+class RemoveUnnecessaryConstBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_const;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class C { const C(); }
+class D { const D(C c); }
+const c = const C();
+const list = const [];
+var d = const D(const C());
+''');
+ await assertHasFix('''
+class C { const C(); }
+class D { const D(C c); }
+const c = C();
+const list = [];
+var d = const D(C());
+''');
+ }
+}
+
+@reflectiveTest
class RemoveUnnecessaryConstTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_UNNECESSARY_CONST;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_new_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_new_test.dart
index dc6b443..5ad35bf 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_new_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_new_test.dart
@@ -11,11 +11,43 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveUnnecessaryNewBulkTest);
defineReflectiveTests(RemoveUnnecessaryNewTest);
});
}
@reflectiveTest
+class RemoveUnnecessaryNewBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_new;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+C f() => new C();
+
+class C {
+ C();
+
+ void m() {
+ new C();
+ }
+}
+''');
+ await assertHasFix('''
+C f() => C();
+
+class C {
+ C();
+
+ void m() {
+ C();
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveUnnecessaryNewTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_UNNECESSARY_NEW;
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 166007e..487f677 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
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart
index 2304921..7b9f86d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_escapes_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_interpolation_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_interpolation_test.dart
index cd6a3c4..7cd247c 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_interpolation_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/remove_unnecessary_string_interpolation_test.dart
@@ -11,11 +11,45 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RemoveUnnecessaryStringInterpolationBulkTest);
defineReflectiveTests(RemoveUnnecessaryStringInterpolationTest);
});
}
@reflectiveTest
+class RemoveUnnecessaryStringInterpolationBulkTest
+ extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_string_interpolations;
+
+ Future<void> test_embedded_removeBoth() async {
+ await resolveTestCode(r'''
+void f(String s) {
+ print('${'$s'}');
+}
+''');
+ await assertHasFix(r'''
+void f(String s) {
+ print(s);
+}
+''');
+ }
+
+ Future<void> test_embedded_removeOuter() async {
+ await resolveTestCode(r'''
+void f(String s) {
+ print('${'$s '}');
+}
+''');
+ await assertHasFix(r'''
+void f(String s) {
+ print('$s ');
+}
+''');
+ }
+}
+
+@reflectiveTest
class RemoveUnnecessaryStringInterpolationTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REMOVE_UNNECESSARY_STRING_INTERPOLATION;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
index e582716..806eb6b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/rename_to_camel_case_test.dart
@@ -11,11 +11,43 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(RenameToCamelCaseBulkTest);
defineReflectiveTests(RenameToCamelCaseTest);
});
}
@reflectiveTest
+class RenameToCamelCaseBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.non_constant_identifier_names;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+main() {
+ int my_integer_variable = 42;
+ int foo;
+ print(my_integer_variable);
+ print(foo);
+ [0, 1, 2].forEach((my_integer_variable) {
+ print(my_integer_variable);
+ });
+}
+''');
+ await assertHasFix('''
+main() {
+ int myIntegerVariable = 42;
+ int foo;
+ print(myIntegerVariable);
+ print(foo);
+ [0, 1, 2].forEach((myIntegerVariable) {
+ print(myIntegerVariable);
+ });
+}
+''');
+ }
+}
+
+@reflectiveTest
class RenameToCamelCaseTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.RENAME_TO_CAMEL_CASE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart
index 852892b..6c5fb20 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_colon_with_equals_test.dart
@@ -11,11 +11,35 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceColonWithEqualsBulkTest);
defineReflectiveTests(ReplaceColonWithEqualsTest);
});
}
@reflectiveTest
+class ReplaceColonWithEqualsBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_equal_for_default_values;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f({int a: 1}) => null;
+
+class C {
+ void m({int a: 1, int b: 2}) => null;
+}
+''');
+ await assertHasFix('''
+void f({int a = 1}) => null;
+
+class C {
+ void m({int a = 1, int b = 2}) => null;
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceColonWithEqualsTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_COLON_WITH_EQUALS;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart
index e1ffdad..7cb0d8d 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_const_test.dart
@@ -11,11 +11,29 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceFinalWithConstBulkTest);
defineReflectiveTests(ReplaceFinalWithConstTest);
});
}
@reflectiveTest
+class ReplaceFinalWithConstBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_const_declarations;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+final int a = 1;
+final b = 1;
+''');
+ await assertHasFix('''
+const int a = 1;
+const b = 1;
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceFinalWithConstTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_FINAL_WITH_CONST;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_var_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_var_test.dart
index e13d52a..2742311 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_var_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_final_with_var_test.dart
@@ -7,7 +7,6 @@
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart
index a1607e5..6960bb5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_new_with_const_test.dart
@@ -11,11 +11,39 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceNewWithConstBulkTest);
defineReflectiveTests(ReplaceNewWithConstTest);
});
}
@reflectiveTest
+class ReplaceNewWithConstBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_const_constructors;
+
+ /// Disabled in BulkFixProcessor.
+ @failingTest
+ Future<void> test_singleFile() async {
+ await resolveTestCode(r'''
+class C {
+ const C();
+}
+main() {
+ print('${new C()} ${new C()}');
+}
+''');
+ await assertHasFix(r'''
+class C {
+ const C();
+}
+main() {
+ print('${const C()} ${const C()}');
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceNewWithConstTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_NEW_WITH_CONST;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_null_with_closure_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_null_with_closure_test.dart
index 3842dba..1e779b7 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_null_with_closure_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_null_with_closure_test.dart
@@ -11,11 +11,39 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceNullWithClosureBulkTest);
defineReflectiveTests(ReplaceNullWithClosureTest);
});
}
@reflectiveTest
+class ReplaceNullWithClosureBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.null_closures;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f(List<int> l) {
+ l.firstWhere((e) => e.isEven, orElse: null);
+}
+
+void f2(String s) {
+ s.splitMapJoin('', onNonMatch: null);
+}
+''');
+ await assertHasFix('''
+void f(List<int> l) {
+ l.firstWhere((e) => e.isEven, orElse: () => null);
+}
+
+void f2(String s) {
+ s.splitMapJoin('', onNonMatch: (String p1) => null);
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceNullWithClosureTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_NULL_WITH_CLOSURE;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_conditional_assignment_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_conditional_assignment_test.dart
index c8c67fd..1cb267b8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_conditional_assignment_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_conditional_assignment_test.dart
@@ -11,11 +11,48 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceWithConditionalAssignmentBulkTest);
defineReflectiveTests(ReplaceWithConditionalAssignmentTest);
});
}
@reflectiveTest
+class ReplaceWithConditionalAssignmentBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_conditional_assignment;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+class Person {
+ String _fullName;
+ void foo() {
+ if (_fullName == null) {
+ _fullName = getFullUserName(this);
+ }
+ }
+ void bar() {
+ if (_fullName == null)
+ _fullName = getFullUserName(this);
+ }
+ String getFullUserName(Person p) => '';
+}
+''');
+ await assertHasFix('''
+class Person {
+ String _fullName;
+ void foo() {
+ _fullName ??= getFullUserName(this);
+ }
+ void bar() {
+ _fullName ??= getFullUserName(this);
+ }
+ String getFullUserName(Person p) => '';
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceWithConditionalAssignmentTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_WITH_CONDITIONAL_ASSIGNMENT;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_is_empty_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_is_empty_test.dart
index ebff731..9aa8d2f 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_is_empty_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_is_empty_test.dart
@@ -11,11 +11,33 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceWithIsEmptyBulkTest);
defineReflectiveTests(ReplaceWithIsEmptyTest);
});
}
@reflectiveTest
+class ReplaceWithIsEmptyBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_is_empty;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f(List c) {
+ if (0 == c.length) {}
+ if (1 > c.length) {}
+}
+''');
+ await assertHasFix('''
+void f(List c) {
+ if (c.isEmpty) {}
+ if (c.isEmpty) {}
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceWithIsEmptyTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_WITH_IS_EMPTY;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
index 35c3f0c..edd6679 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_not_null_aware_test.dart
@@ -7,7 +7,6 @@
import 'package:test_reflective_loader/test_reflective_loader.dart';
import '../../../../abstract_context.dart';
-import 'bulk/bulk_fix_processor.dart';
import 'fix_processor.dart';
void main() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_tear_off_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_tear_off_test.dart
index 772ecd7..52898ab 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_tear_off_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_tear_off_test.dart
@@ -11,11 +11,41 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceWithTearOffBulkTest);
defineReflectiveTests(ReplaceWithTearOffTest);
});
}
@reflectiveTest
+class ReplaceWithTearOffBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.unnecessary_lambdas;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+Function f() => (name) {
+ print(name);
+};
+
+void foo(){}
+Function f2() {
+ return () {
+ foo();
+ };
+}
+''');
+ await assertHasFix('''
+Function f() => print;
+
+void foo(){}
+Function f2() {
+ return foo;
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceWithTearOffTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_WITH_TEAR_OFF;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/replace_with_var_test.dart b/pkg/analysis_server/test/src/services/correction/fix/replace_with_var_test.dart
index 422034e..a1c78e8 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/replace_with_var_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/replace_with_var_test.dart
@@ -11,11 +11,45 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(ReplaceWithVarBulkTest);
defineReflectiveTests(ReplaceWithVarTest);
});
}
@reflectiveTest
+class ReplaceWithVarBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.omit_local_variable_types;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+List f() {
+ List<int> l = [];
+ return l;
+}
+
+void f2(List<int> list) {
+ for (int i in list) {
+ print(i);
+ }
+}
+''');
+ await assertHasFix('''
+List f() {
+ var l = <int>[];
+ return l;
+}
+
+void f2(List<int> list) {
+ for (var i in list) {
+ print(i);
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class ReplaceWithVarTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.REPLACE_WITH_VAR;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart b/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
index 686d8f2..b571ad5 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/sort_child_property_last_test.dart
@@ -11,11 +11,62 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(SortChildPropertyLastBulkTest);
defineReflectiveTests(SortChildPropertyLastTest);
});
}
@reflectiveTest
+class SortChildPropertyLastBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.sort_child_properties_last;
+
+ Future<void> test_singleFile() async {
+ writeTestPackageConfig(flutter: true);
+ await resolveTestCode('''
+import 'package:flutter/material.dart';
+main() {
+ Column(
+ children: [
+ Column(
+ children: [
+ Text('a'),
+ ],
+ crossAxisAlignment: CrossAxisAlignment.center,
+ ),
+ Text('b'),
+ Text('c'),
+ Text('d'),
+ ],
+ crossAxisAlignment: CrossAxisAlignment.center,
+ );
+}
+''');
+ // todo (pq): two diagnostics are produced but only the first is fixed.
+ // see: linter/test/rules/sort_child_properties_last.dart:nestedChildren()
+ await assertHasFix('''
+import 'package:flutter/material.dart';
+main() {
+ Column(
+ crossAxisAlignment: CrossAxisAlignment.center,
+ children: [
+ Column(
+ children: [
+ Text('a'),
+ ],
+ crossAxisAlignment: CrossAxisAlignment.center,
+ ),
+ Text('b'),
+ Text('c'),
+ Text('d'),
+ ],
+ );
+}
+''');
+ }
+}
+
+@reflectiveTest
class SortChildPropertyLastTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.SORT_CHILD_PROPERTY_LAST;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
index 75962a3..c5ba22b 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/test_all.dart
@@ -35,7 +35,7 @@
as add_super_constructor_invocation;
import 'add_type_annotation_test.dart' as add_type_annotation;
import 'analysis_options/test_all.dart' as analysis_options;
-import 'bulk/test_all.dart' as bulk;
+import 'bulk_fix_processor_test.dart' as bulk_fix_processor;
import 'change_argument_name_test.dart' as change_argument_name;
import 'change_to_nearest_precise_value_test.dart'
as change_to_nearest_precise_value;
@@ -48,6 +48,7 @@
import 'convert_flutter_children_test.dart' as convert_flutter_children;
import 'convert_for_each_to_for_loop_test.dart' as convert_for_each_to_for_loop;
import 'convert_into_expression_body_test.dart' as convert_into_expression_body;
+import 'convert_into_is_not_test.dart' as convert_into_is_not;
import 'convert_to_contains_test.dart' as convert_to_contains;
import 'convert_to_for_element_test.dart' as convert_to_for_element;
import 'convert_to_generic_function_syntax_test.dart'
@@ -178,6 +179,7 @@
import 'sort_child_property_last_test.dart' as sort_properties_last;
import 'update_sdk_constraints_test.dart' as update_sdk_constraints;
import 'use_const_test.dart' as use_const;
+import 'use_curly_braces_test.dart' as use_curly_braces;
import 'use_effective_integer_division_test.dart'
as use_effective_integer_division;
import 'use_eq_eq_null_test.dart' as use_eq_eq_null;
@@ -213,7 +215,7 @@
add_super_constructor_invocation.main();
add_type_annotation.main();
analysis_options.main();
- bulk.main();
+ bulk_fix_processor.main();
change_argument_name.main();
change_to.main();
change_to_nearest_precise_value.main();
@@ -224,6 +226,7 @@
convert_flutter_children.main();
convert_for_each_to_for_loop.main();
convert_into_expression_body.main();
+ convert_into_is_not.main();
convert_to_contains.main();
convert_to_for_element.main();
convert_to_generic_function_syntax.main();
@@ -344,6 +347,7 @@
sort_properties_last.main();
update_sdk_constraints.main();
use_const.main();
+ use_curly_braces.main();
use_effective_integer_division.main();
use_eq_eq_null.main();
use_is_not_empty.main();
diff --git a/pkg/analysis_server/test/src/services/correction/fix/bulk/use_curly_braces_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_curly_braces_test.dart
similarity index 96%
rename from pkg/analysis_server/test/src/services/correction/fix/bulk/use_curly_braces_test.dart
rename to pkg/analysis_server/test/src/services/correction/fix/use_curly_braces_test.dart
index 8e1f19a..96931b9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/bulk/use_curly_braces_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_curly_braces_test.dart
@@ -5,7 +5,7 @@
import 'package:analysis_server/src/services/linter/lint_names.dart';
import 'package:test_reflective_loader/test_reflective_loader.dart';
-import 'bulk_fix_processor.dart';
+import 'fix_processor.dart';
void main() {
defineReflectiveSuite(() {
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_is_not_empty_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_is_not_empty_test.dart
index 04a82ac..dcf8d89 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_is_not_empty_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_is_not_empty_test.dart
@@ -11,11 +11,33 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(UseIsNotEmptyBulkTest);
defineReflectiveTests(UseIsNotEmptyTest);
});
}
@reflectiveTest
+class UseIsNotEmptyBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.prefer_is_not_empty;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f(List<int> l) {
+ if (!l.isEmpty) {}
+ if (!l.isEmpty || true) {}
+}
+''');
+ await assertHasFix('''
+void f(List<int> l) {
+ if (l.isNotEmpty) {}
+ if (l.isNotEmpty || true) {}
+}
+''');
+ }
+}
+
+@reflectiveTest
class UseIsNotEmptyTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.USE_IS_NOT_EMPTY;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/use_rethrow_test.dart b/pkg/analysis_server/test/src/services/correction/fix/use_rethrow_test.dart
index 6d78eb0..7b20410 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/use_rethrow_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/use_rethrow_test.dart
@@ -11,11 +11,49 @@
void main() {
defineReflectiveSuite(() {
+ defineReflectiveTests(UseRethrowBulkTest);
defineReflectiveTests(UseRethrowTest);
});
}
@reflectiveTest
+class UseRethrowBulkTest extends BulkFixProcessorTest {
+ @override
+ String get lintCode => LintNames.use_rethrow_when_possible;
+
+ Future<void> test_singleFile() async {
+ await resolveTestCode('''
+void f() {
+ try {} catch (e) {
+ throw e;
+ }
+}
+
+void f2() {
+ try {} catch (e, stackTrace) {
+ print(stackTrace);
+ throw e;
+ }
+}
+''');
+ await assertHasFix('''
+void f() {
+ try {} catch (e) {
+ rethrow;
+ }
+}
+
+void f2() {
+ try {} catch (e, stackTrace) {
+ print(stackTrace);
+ rethrow;
+ }
+}
+''');
+ }
+}
+
+@reflectiveTest
class UseRethrowTest extends FixProcessorLintTest {
@override
FixKind get kind => DartFixKind.USE_RETHROW;
diff --git a/sdk/lib/_http/http_headers.dart b/sdk/lib/_http/http_headers.dart
index 77b9c22..09e5748 100644
--- a/sdk/lib/_http/http_headers.dart
+++ b/sdk/lib/_http/http_headers.dart
@@ -421,8 +421,13 @@
void _addHost(String name, value) {
if (value is String) {
- int pos = value.indexOf(":");
- if (pos == -1) {
+ // value.indexOf will only work for ipv4, ipv6 which has multiple : in its
+ // host part needs lastIndexOf
+ int pos = value.lastIndexOf(":");
+ // According to RFC 3986, section 3.2.2, host part of ipv6 address must be
+ // enclosed by square brackets.
+ // https://serverfault.com/questions/205793/how-can-one-distinguish-the-host-and-the-port-in-an-ipv6-url
+ if (pos == -1 || value.startsWith("[") && value.endsWith("]")) {
_host = value;
_port = HttpClient.defaultHttpPort;
} else {
diff --git a/tests/standalone/io/http_headers_test.dart b/tests/standalone/io/http_headers_test.dart
index 11e0f89..f2cfb6c 100644
--- a/tests/standalone/io/http_headers_test.dart
+++ b/tests/standalone/io/http_headers_test.dart
@@ -173,6 +173,40 @@
Expect.equals(":1234", headers.value(HttpHeaders.hostHeader));
Expect.isNull(headers.host);
Expect.equals(1234, headers.port);
+
+ // ipv4
+ host = "123.45.67.89";
+ int port = 1234;
+ headers = new _HttpHeaders("1.1");
+ headers.add(HttpHeaders.hostHeader, "$host:$port");
+ Expect.equals("$host:$port", headers.value(HttpHeaders.hostHeader));
+ Expect.equals(host, headers.host);
+ Expect.equals(port, headers.port);
+
+ // ipv6: host+port
+ host = "[2001:db8::1]";
+ port = 1234;
+ headers = new _HttpHeaders("1.1");
+ headers.add(HttpHeaders.hostHeader, "$host:$port");
+ Expect.equals("$host:$port", headers.value(HttpHeaders.hostHeader));
+ Expect.equals(host, headers.host);
+ Expect.equals(port, headers.port);
+
+ // ipv6: host only
+ host = "[2001:db8::1]";
+ headers = new _HttpHeaders("1.1");
+ headers.add(HttpHeaders.hostHeader, "$host");
+ Expect.equals("$host", headers.value(HttpHeaders.hostHeader));
+ Expect.equals(host, headers.host);
+ Expect.equals(headers.port, HttpClient.defaultHttpPort);
+
+ // ipv6: host + invalid port
+ host = "[2001:db8::1]";
+ headers = new _HttpHeaders("1.1");
+ headers.add(HttpHeaders.hostHeader, "$host:xxx");
+ Expect.equals("$host:xxx", headers.value(HttpHeaders.hostHeader));
+ Expect.equals(host, headers.host);
+ Expect.isNull(headers.port);
}
void testTransferEncoding() {
diff --git a/tools/VERSION b/tools/VERSION
index 438d0ba..4d5e8b0 100644
--- a/tools/VERSION
+++ b/tools/VERSION
@@ -27,5 +27,5 @@
MAJOR 2
MINOR 14
PATCH 0
-PRERELEASE 264
+PRERELEASE 265
PRERELEASE_PATCH 0
\ No newline at end of file