Skip to content

Commit f30e5de

Browse files
srawlinsCommit Queue
authored and
Commit Queue
committed
Remove preview-dart-2 option in analysis options
Fixes #50680 AnalysisOptionsHintCode is moved from generated `option_codes.g.dart` to `option_codes.dart`, for non-generated diagnostics: * AnalysisOptionsHintCode.DEPRECATED_LINT_HINT and * AnalysisOptionsHintCode.DUPLICATE_RULE_HINT Change-Id: I131fb2901fca26ff971b6c9c519ab2f0b983a65c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/275500 Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Konstantin Shcheglov <[email protected]>
1 parent 4baa958 commit f30e5de

File tree

10 files changed

+26
-78
lines changed

10 files changed

+26
-78
lines changed

pkg/analysis_server/lib/src/services/correction/error_fix_status.yaml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,6 @@ AnalysisOptionsErrorCode.PARSE_ERROR:
4040
notes: |-
4141
Because of the way the YAML parser works, there isn't enough information to
4242
be able to provide a fix.
43-
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED:
44-
status: needsFix
45-
notes: Fixed.
4643
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND:
4744
status: noFix
4845
notes: |-

pkg/analysis_server/lib/src/services/correction/fix/analysis_options/fix_generator.dart

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,7 @@ class AnalysisOptionsFixGenerator {
6262
// if (errorCode == AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR) {
6363
// } else if (errorCode == AnalysisOptionsErrorCode.PARSE_ERROR) {
6464
// } else
65-
if (errorCode ==
66-
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED) {
67-
await _addFix_removeSetting(coveringNodePath);
68-
} else if (errorCode == DEPRECATED_LINT_HINT) {
65+
if (errorCode == DEPRECATED_LINT_HINT) {
6966
await _addFix_removeLint(coveringNodePath);
7067
// } else if (errorCode == AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING) {
7168
// } else if (errorCode == AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND) {

pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_setting_test.dart

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,20 +14,6 @@ void main() {
1414

1515
@reflectiveTest
1616
class RemoveSettingTest extends AnalysisOptionsFixTest {
17-
Future<void> test_enablePreviewDart2() async {
18-
await assertHasFix('''
19-
analyzer:
20-
enable-experiment:
21-
- test-experiment
22-
language:
23-
enablePreviewDart2: true
24-
''', '''
25-
analyzer:
26-
enable-experiment:
27-
- test-experiment
28-
''');
29-
}
30-
3117
Future<void> test_invalidExperiment_first() async {
3218
await assertHasFix('''
3319
analyzer:

pkg/analyzer/lib/src/analysis_options/error/option_codes.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,28 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5+
import 'package:analyzer/error/error.dart';
6+
57
export 'package:analyzer/src/analysis_options/error/option_codes.g.dart';
8+
9+
class AnalysisOptionsHintCode extends ErrorCode {
10+
/// Initialize a newly created error code to have the given [name].
11+
const AnalysisOptionsHintCode(
12+
String name,
13+
String problemMessage, {
14+
super.correctionMessage,
15+
super.hasPublishedDocs = false,
16+
super.isUnresolvedIdentifier = false,
17+
String? uniqueName,
18+
}) : super(
19+
name: name,
20+
problemMessage: problemMessage,
21+
uniqueName: 'AnalysisOptionsHintCode.${uniqueName ?? name}',
22+
);
23+
24+
@override
25+
ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
26+
27+
@override
28+
ErrorType get type => ErrorType.HINT;
29+
}

pkg/analyzer/lib/src/analysis_options/error/option_codes.g.dart

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -58,37 +58,6 @@ class AnalysisOptionsErrorCode extends ErrorCode {
5858
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
5959
}
6060

61-
class AnalysisOptionsHintCode extends ErrorCode {
62-
/// An error code indicating that the enablePreviewDart2 setting is
63-
/// deprecated.
64-
static const AnalysisOptionsHintCode PREVIEW_DART_2_SETTING_DEPRECATED =
65-
AnalysisOptionsHintCode(
66-
'PREVIEW_DART_2_SETTING_DEPRECATED',
67-
"The 'enablePreviewDart2' setting is deprecated.",
68-
correctionMessage: "It is no longer necessary to explicitly enable Dart 2.",
69-
);
70-
71-
/// Initialize a newly created error code to have the given [name].
72-
const AnalysisOptionsHintCode(
73-
String name,
74-
String problemMessage, {
75-
super.correctionMessage,
76-
super.hasPublishedDocs = false,
77-
super.isUnresolvedIdentifier = false,
78-
String? uniqueName,
79-
}) : super(
80-
name: name,
81-
problemMessage: problemMessage,
82-
uniqueName: 'AnalysisOptionsHintCode.${uniqueName ?? name}',
83-
);
84-
85-
@override
86-
ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
87-
88-
@override
89-
ErrorType get type => ErrorType.HINT;
90-
}
91-
9261
class AnalysisOptionsWarningCode extends ErrorCode {
9362
/// An error code indicating a specified include file has a warning.
9463
///

pkg/analyzer/lib/src/error/error_code_values.g.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@ import 'package:analyzer/src/pubspec/pubspec_warning_code.dart';
2222
const List<ErrorCode> errorCodeValues = [
2323
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR,
2424
AnalysisOptionsErrorCode.PARSE_ERROR,
25-
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED,
2625
AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING,
2726
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
2827
AnalysisOptionsWarningCode.INVALID_OPTION,

pkg/analyzer/lib/src/lint/analysis.dart

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -82,13 +82,6 @@ class DriverOptions {
8282
set enableAssertInitializer(bool enable) {
8383
// Ignored because the option is now always enabled.
8484
}
85-
86-
/// Whether to use Dart 2.0 features.
87-
@deprecated
88-
bool get previewDart2 => true;
89-
90-
@deprecated
91-
set previewDart2(bool value) {}
9285
}
9386

9487
class LintDriver {

pkg/analyzer/lib/src/task/options.dart

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@ void applyToAnalysisOptions(AnalysisOptionsImpl options, YamlMap optionMap) {
118118
/// `analyzer` analysis options constants.
119119
class AnalyzerOptions {
120120
static const String analyzer = 'analyzer';
121-
static const String enablePreviewDart2 = 'enablePreviewDart2';
122121

123122
static const String cannotIgnore = 'cannot-ignore';
124123
static const String codeStyle = 'code-style';
@@ -490,11 +489,7 @@ class LanguageOptionValidator extends OptionsValidator {
490489
bool validKey = false;
491490
if (k is YamlScalar) {
492491
key = k.value?.toString();
493-
if (AnalyzerOptions.enablePreviewDart2 == key) {
494-
reporter.reportErrorForSpan(
495-
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED,
496-
k.span);
497-
} else if (!AnalyzerOptions.languageOptions.contains(key)) {
492+
if (!AnalyzerOptions.languageOptions.contains(key)) {
498493
_builder.reportError(reporter, AnalyzerOptions.language, k);
499494
} else {
500495
// If we have a valid key, go on and check the value.

pkg/analyzer/messages.yaml

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -53,13 +53,6 @@ AnalysisOptionsErrorCode:
5353

5454
Parameters:
5555
0: the error message from the parse error
56-
AnalysisOptionsHintCode:
57-
PREVIEW_DART_2_SETTING_DEPRECATED:
58-
problemMessage: "The 'enablePreviewDart2' setting is deprecated."
59-
correctionMessage: It is no longer necessary to explicitly enable Dart 2.
60-
comment: |-
61-
An error code indicating that the enablePreviewDart2 setting is
62-
deprecated.
6356
AnalysisOptionsWarningCode:
6457
INCLUDED_FILE_WARNING:
6558
problemMessage: "Warning in the included options file {0}({1}..{2}): {3}"

pkg/analyzer/tool/messages/error_code_info.dart

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,6 @@ const List<ErrorClassInfo> errorClasses = [
1818
name: 'AnalysisOptionsErrorCode',
1919
type: 'COMPILE_TIME_ERROR',
2020
severity: 'ERROR'),
21-
ErrorClassInfo(
22-
filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
23-
name: 'AnalysisOptionsHintCode',
24-
type: 'HINT',
25-
severity: 'INFO'),
2621
ErrorClassInfo(
2722
filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
2823
name: 'AnalysisOptionsWarningCode',

0 commit comments

Comments
 (0)