diff --git a/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart b/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart index f4c17458dd4..185a29163a1 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/add_async_test.dart @@ -4,11 +4,11 @@ import 'package:analysis_server/src/services/correction/fix.dart'; import 'package:analysis_server/src/services/linter/lint_names.dart'; -import 'package:analyzer/src/dart/analysis/experiments.dart'; import 'package:analyzer/src/error/codes.dart'; import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; +import '../../../../abstract_context.dart'; import 'fix_processor.dart'; void main() { @@ -216,10 +216,8 @@ main() async { } @reflectiveTest -class AddAsyncWithNullSafetyTest extends FixProcessorTest { - @override - List get experiments => [EnableString.non_nullable]; - +class AddAsyncWithNullSafetyTest extends FixProcessorTest + with WithNullSafetyMixin { @override FixKind get kind => DartFixKind.ADD_ASYNC; 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 321da9d498e..0900c1b30ec 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 @@ -7,11 +7,9 @@ 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'; import 'package:analysis_server/src/services/correction/fix_internal.dart'; -import 'package:analyzer/dart/analysis/features.dart'; import 'package:analyzer/error/error.dart'; import 'package:analyzer/instrumentation/service.dart'; import 'package:analyzer/src/dart/analysis/byte_store.dart'; -import 'package:analyzer/src/dart/analysis/experiments.dart'; import 'package:analyzer/src/dart/error/lint_codes.dart'; import 'package:analyzer/src/services/available_declarations.dart'; import 'package:analyzer/src/test_utilities/platform.dart'; @@ -40,8 +38,11 @@ abstract class FixProcessorLintTest extends FixProcessorTest { } @override - void _createAnalysisOptionsFile() { - createAnalysisOptionsFile(experiments: experiments, lints: [lintCode]); + void setUp() { + super.setUp(); + createAnalysisOptionsFile( + lints: [lintCode], + ); } } @@ -58,10 +59,6 @@ abstract class FixProcessorTest extends AbstractSingleUnitTest { /// neither [assertHasFix] nor [assertHasFixAllFix] has been invoked. 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 get experiments => null; - /// Return the kind of fixes being tested by this test class. FixKind get kind; @@ -166,7 +163,6 @@ abstract class FixProcessorTest extends AbstractSingleUnitTest { super.setUp(); verifyNoTestUnitErrors = false; useLineEndingsForPlatform = true; - _createAnalysisOptionsFile(); } /// Computes fixes and verifies that there is a fix for the given [error] of the appropriate kind. @@ -291,12 +287,6 @@ abstract class FixProcessorTest extends AbstractSingleUnitTest { return await DartFixContributor().computeFixes(context); } - /// Create the analysis options file needed in order to correctly analyze the - /// test file. - void _createAnalysisOptionsFile() { - createAnalysisOptionsFile(experiments: experiments); - } - /// Find the error that is to be fixed by computing the errors in the file, /// using the [errorFilter] to filter out errors that should be ignored, and /// expecting that there is a single remaining error. The error filter should @@ -349,16 +339,14 @@ mixin WithNullSafetyLintMixin on AbstractContextTest { String get lintCode; @override - String get testPackageLanguageVersion => - Feature.non_nullable.isEnabledByDefault ? '2.12' : '2.11'; + String get testPackageLanguageVersion => '2.12'; - /// TODO(scheglov) https://github.com/dart-lang/sdk/issues/43837 - /// Remove when Null Safety is enabled by default. @nonVirtual @override void setUp() { super.setUp(); createAnalysisOptionsFile( - experiments: [EnableString.non_nullable], lints: [lintCode]); + lints: [lintCode], + ); } } diff --git a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart index 62618ace612..3fd394ea84f 100644 --- a/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart +++ b/pkg/analysis_server/test/src/services/correction/fix/remove_dead_code_test.dart @@ -3,10 +3,10 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analysis_server/src/services/correction/fix.dart'; -import 'package:analyzer/src/dart/analysis/experiments.dart'; import 'package:analyzer_plugin/utilities/fixes/fixes.dart'; import 'package:test_reflective_loader/test_reflective_loader.dart'; +import '../../../../abstract_context.dart'; import 'fix_processor.dart'; void main() { @@ -140,10 +140,8 @@ int main() { } @reflectiveTest -class RemoveDeadCodeWithNullSafetyTest extends FixProcessorTest { - @override - List get experiments => [EnableString.non_nullable]; - +class RemoveDeadCodeWithNullSafetyTest extends FixProcessorTest + with WithNullSafetyMixin { @override FixKind get kind => DartFixKind.REMOVE_DEAD_CODE;