Clean up WithNullSafetyLintMixin.

Change-Id: I7b0527def3589449e40619c5d4338c9ca1c3e672
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/174481
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2020-12-01 00:05:39 +00:00 committed by commit-bot@chromium.org
parent 8fee2b96af
commit 5af2d78e75
3 changed files with 14 additions and 30 deletions

View file

@ -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<String> get experiments => [EnableString.non_nullable];
class AddAsyncWithNullSafetyTest extends FixProcessorTest
with WithNullSafetyMixin {
@override
FixKind get kind => DartFixKind.ADD_ASYNC;

View file

@ -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<String> 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],
);
}
}

View file

@ -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<String> get experiments => [EnableString.non_nullable];
class RemoveDeadCodeWithNullSafetyTest extends FixProcessorTest
with WithNullSafetyMixin {
@override
FixKind get kind => DartFixKind.REMOVE_DEAD_CODE;