mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 08:24:39 +00:00
Revert "Use Feature to specify experiments."
This reverts commit fce81082c0
.
Reason for revert: I changed my mind, specifically about using something else than `String` in `AnalysisOptionsFileConfig`.
Original change's description:
> Use Feature to specify experiments.
>
> Change-Id: Ide1a58c93cfc4920dff3ab2f52113434de93fff0
> Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288162
> Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
> Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Change-Id: Ib6eb1c04c099e318e935e9761f12bf35f561389f
No-Presubmit: true
No-Tree-Checks: true
No-Try: true
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/288260
Auto-Submit: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Bot-Commit: Rubber Stamper <rubber-stamper@appspot.gserviceaccount.com>
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
f51fedce26
commit
6c7f3ab27d
|
@ -3,7 +3,6 @@
|
|||
// BSD-style license that can be found in the LICENSE file.
|
||||
|
||||
import 'package:analyzer/dart/analysis/analysis_context.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/dart/analysis/results.dart';
|
||||
import 'package:analyzer/dart/analysis/session.dart';
|
||||
import 'package:analyzer/file_system/file_system.dart';
|
||||
|
@ -45,12 +44,12 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
|
||||
/// Return a list of the experiments that are to be enabled for tests in this
|
||||
/// class, an empty list if there are no experiments that should be enabled.
|
||||
List<Feature> get experiments => [
|
||||
Feature.class_modifiers,
|
||||
Feature.macros,
|
||||
Feature.patterns,
|
||||
Feature.records,
|
||||
Feature.sealed_class,
|
||||
List<String> get experiments => [
|
||||
EnableString.class_modifiers,
|
||||
EnableString.macros,
|
||||
EnableString.patterns,
|
||||
EnableString.records,
|
||||
EnableString.sealed_class,
|
||||
];
|
||||
|
||||
String get latestLanguageVersion =>
|
||||
|
@ -106,7 +105,7 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
|
||||
/// Create an analysis options file based on the given arguments.
|
||||
void createAnalysisOptionsFile({
|
||||
List<Feature>? experiments,
|
||||
List<String>? experiments,
|
||||
List<String>? cannotIgnore,
|
||||
bool? implicitCasts,
|
||||
List<String>? lints,
|
||||
|
@ -120,12 +119,7 @@ class AbstractContextTest with ResourceProviderMixin {
|
|||
if (experiments != null) {
|
||||
buffer.writeln(' enable-experiment:');
|
||||
for (var experiment in experiments) {
|
||||
final experimentalFlag = experiment.experimentalFlag;
|
||||
if (experimentalFlag != null) {
|
||||
buffer.writeln(' - ${experiment.experimentalFlag}');
|
||||
} else {
|
||||
throw ArgumentError('Not experimental: $experiment');
|
||||
}
|
||||
buffer.writeln(' - $experiment');
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -7,6 +7,7 @@ import 'dart:async';
|
|||
import 'package:analysis_server/protocol/protocol.dart';
|
||||
import 'package:analysis_server/protocol/protocol_constants.dart';
|
||||
import 'package:analysis_server/protocol/protocol_generated.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/source/source_range.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:analyzer_plugin/protocol/protocol_common.dart';
|
||||
|
@ -25,6 +26,12 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class AnalysisNotificationHighlightsTest extends HighlightsTestSupport {
|
||||
@override
|
||||
List<String> get experiments => [
|
||||
Feature.inline_class.enableString,
|
||||
...super.experiments,
|
||||
];
|
||||
|
||||
void assertHighlightText(TestCode testCode, int index, String expected) {
|
||||
var actual = _getHighlightText(testCode, index);
|
||||
if (actual != expected) {
|
||||
|
|
|
@ -27,7 +27,7 @@ import 'src/utilities/mock_packages.dart';
|
|||
|
||||
/// TODO(scheglov) this is duplicate
|
||||
class AnalysisOptionsFileConfig {
|
||||
final List<Feature> experiments;
|
||||
final List<String> experiments;
|
||||
final bool implicitCasts;
|
||||
final bool implicitDynamic;
|
||||
final List<String> lints;
|
||||
|
@ -52,12 +52,7 @@ class AnalysisOptionsFileConfig {
|
|||
if (experiments.isNotEmpty) {
|
||||
buffer.writeln(' enable-experiment:');
|
||||
for (var experiment in experiments) {
|
||||
final experimentalFlag = experiment.experimentalFlag;
|
||||
if (experimentalFlag != null) {
|
||||
buffer.writeln(' - ${experiment.experimentalFlag}');
|
||||
} else {
|
||||
throw ArgumentError('Not experimental: $experiment');
|
||||
}
|
||||
buffer.writeln(' - $experiment');
|
||||
}
|
||||
}
|
||||
buffer.writeln(' language:');
|
||||
|
@ -219,13 +214,15 @@ class ContextResolutionTest with ResourceProviderMixin {
|
|||
}
|
||||
|
||||
class PubPackageAnalysisServerTest extends ContextResolutionTest {
|
||||
List<Feature> get experiments => [
|
||||
Feature.class_modifiers,
|
||||
Feature.inline_class,
|
||||
Feature.macros,
|
||||
Feature.patterns,
|
||||
Feature.records,
|
||||
Feature.sealed_class,
|
||||
// If experiments are needed,
|
||||
// add `import 'package:analyzer/dart/analysis/features.dart';`
|
||||
// and list the necessary experiments here.
|
||||
List<String> get experiments => [
|
||||
Feature.class_modifiers.enableString,
|
||||
Feature.macros.enableString,
|
||||
Feature.patterns.enableString,
|
||||
Feature.records.enableString,
|
||||
Feature.sealed_class.enableString,
|
||||
];
|
||||
|
||||
/// The path that is not in [workspaceRootPath], contains external packages.
|
||||
|
|
|
@ -11,6 +11,7 @@ import 'package:analysis_server/src/provisional/completion/dart/completion_dart.
|
|||
import 'package:analysis_server/src/services/completion/dart/completion_manager.dart';
|
||||
import 'package:analysis_server/src/services/completion/dart/imported_reference_contributor.dart';
|
||||
import 'package:analysis_server/src/services/completion/dart/suggestion_builder.dart';
|
||||
import 'package:analyzer/src/dart/analysis/experiments.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -2393,6 +2394,7 @@ class B extends A {
|
|||
}
|
||||
|
||||
Future<void> test_function_parameters_nnbd_required() async {
|
||||
createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
|
||||
resolveSource('$testPackageLibPath/a.dart', '''
|
||||
void m(int? nullable, int nonNullable) {}
|
||||
''');
|
||||
|
@ -2415,6 +2417,7 @@ void f() {^}
|
|||
}
|
||||
|
||||
Future<void> test_function_parameters_nnbd_required_into_legacy() async {
|
||||
createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
|
||||
resolveSource('$testPackageLibPath/a.dart', '''
|
||||
void m(int? nullable, int nonNullable) {}
|
||||
''');
|
||||
|
@ -2438,6 +2441,7 @@ void f() {^}
|
|||
}
|
||||
|
||||
Future<void> test_function_parameters_nnbd_required_legacy() async {
|
||||
createAnalysisOptionsFile(experiments: [EnableString.non_nullable]);
|
||||
resolveSource('$testPackageLibPath/a.dart', '''
|
||||
// @dart = 2.8
|
||||
void m(int param) {}
|
||||
|
|
|
@ -7,7 +7,6 @@ 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_internal.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer/error/error.dart';
|
||||
import 'package:analyzer/src/dart/analysis/byte_store.dart';
|
||||
import 'package:analyzer/src/dart/error/lint_codes.dart';
|
||||
|
@ -88,7 +87,7 @@ abstract class BulkFixProcessorTest extends AbstractSingleUnitTest {
|
|||
late BulkFixProcessor processor;
|
||||
|
||||
@override
|
||||
List<Feature> get experiments => const [];
|
||||
List<String> get experiments => const [];
|
||||
|
||||
/// Return the lint code being tested.
|
||||
String? get lintCode => null;
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
import 'package:analysis_server/src/services/correction/fix.dart';
|
||||
import 'package:analysis_server/src/services/linter/lint_names.dart';
|
||||
import 'package:analyzer/dart/analysis/features.dart';
|
||||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
||||
|
@ -20,7 +19,7 @@ void main() {
|
|||
@reflectiveTest
|
||||
class RemoveBreakBulkTest extends BulkFixProcessorTest {
|
||||
@override
|
||||
List<Feature> get experiments => [Feature.patterns, Feature.records];
|
||||
List<String> get experiments => ['patterns', 'records'];
|
||||
|
||||
@override
|
||||
String get lintCode => LintNames.unnecessary_breaks;
|
||||
|
@ -54,7 +53,7 @@ f() {
|
|||
@reflectiveTest
|
||||
class RemoveBreakTest extends FixProcessorLintTest {
|
||||
@override
|
||||
List<Feature> get experiments => [Feature.patterns, Feature.records];
|
||||
List<String> get experiments => ['patterns', 'records'];
|
||||
|
||||
@override
|
||||
FixKind get kind => DartFixKind.REMOVE_BREAK;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
// 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';
|
||||
|
||||
|
@ -63,6 +64,8 @@ const c = a == null;
|
|||
}
|
||||
|
||||
Future<void> test_gtGtGtOperator() async {
|
||||
writeTestPackageConfig(languageVersion: latestLanguageVersion);
|
||||
createAnalysisOptionsFile(experiments: [EnableString.triple_shift]);
|
||||
await testUpdate(content: '''
|
||||
class C {
|
||||
C operator >>>(C other) => this;
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
import 'package:analysis_server/src/utilities/selection.dart';
|
||||
import 'package:analyzer/dart/ast/ast.dart';
|
||||
import 'package:analyzer/source/source_range.dart';
|
||||
import 'package:analyzer/src/dart/analysis/experiments.dart';
|
||||
import 'package:analyzer/src/test_utilities/test_code_format.dart';
|
||||
import 'package:test/test.dart';
|
||||
import 'package:test_reflective_loader/test_reflective_loader.dart';
|
||||
|
@ -20,6 +21,12 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class SelectionTest extends AbstractSingleUnitTest {
|
||||
@override
|
||||
List<String> get experiments => [
|
||||
...super.experiments,
|
||||
EnableString.patterns,
|
||||
];
|
||||
|
||||
Future<void> assertMembers(
|
||||
{String prefix = '', required String postfix}) async {
|
||||
var nodes = await nodesInRange('''
|
||||
|
|
Loading…
Reference in a new issue