mirror of
https://github.com/dart-lang/sdk
synced 2024-09-05 16:41:07 +00:00
Remove preview-dart-2 option in analysis options
Fixes https://github.com/dart-lang/sdk/issues/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 <brianwilkerson@google.com> Commit-Queue: Samuel Rawlins <srawlins@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
parent
4baa958d08
commit
f30e5de558
|
@ -40,9 +40,6 @@ AnalysisOptionsErrorCode.PARSE_ERROR:
|
|||
notes: |-
|
||||
Because of the way the YAML parser works, there isn't enough information to
|
||||
be able to provide a fix.
|
||||
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED:
|
||||
status: needsFix
|
||||
notes: Fixed.
|
||||
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND:
|
||||
status: noFix
|
||||
notes: |-
|
||||
|
|
|
@ -62,10 +62,7 @@ class AnalysisOptionsFixGenerator {
|
|||
// if (errorCode == AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR) {
|
||||
// } else if (errorCode == AnalysisOptionsErrorCode.PARSE_ERROR) {
|
||||
// } else
|
||||
if (errorCode ==
|
||||
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED) {
|
||||
await _addFix_removeSetting(coveringNodePath);
|
||||
} else if (errorCode == DEPRECATED_LINT_HINT) {
|
||||
if (errorCode == DEPRECATED_LINT_HINT) {
|
||||
await _addFix_removeLint(coveringNodePath);
|
||||
// } else if (errorCode == AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING) {
|
||||
// } else if (errorCode == AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND) {
|
||||
|
|
|
@ -14,20 +14,6 @@ void main() {
|
|||
|
||||
@reflectiveTest
|
||||
class RemoveSettingTest extends AnalysisOptionsFixTest {
|
||||
Future<void> test_enablePreviewDart2() async {
|
||||
await assertHasFix('''
|
||||
analyzer:
|
||||
enable-experiment:
|
||||
- test-experiment
|
||||
language:
|
||||
enablePreviewDart2: true
|
||||
''', '''
|
||||
analyzer:
|
||||
enable-experiment:
|
||||
- test-experiment
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_invalidExperiment_first() async {
|
||||
await assertHasFix('''
|
||||
analyzer:
|
||||
|
|
|
@ -2,4 +2,28 @@
|
|||
// 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:analyzer/error/error.dart';
|
||||
|
||||
export 'package:analyzer/src/analysis_options/error/option_codes.g.dart';
|
||||
|
||||
class AnalysisOptionsHintCode extends ErrorCode {
|
||||
/// Initialize a newly created error code to have the given [name].
|
||||
const AnalysisOptionsHintCode(
|
||||
String name,
|
||||
String problemMessage, {
|
||||
super.correctionMessage,
|
||||
super.hasPublishedDocs = false,
|
||||
super.isUnresolvedIdentifier = false,
|
||||
String? uniqueName,
|
||||
}) : super(
|
||||
name: name,
|
||||
problemMessage: problemMessage,
|
||||
uniqueName: 'AnalysisOptionsHintCode.${uniqueName ?? name}',
|
||||
);
|
||||
|
||||
@override
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.HINT;
|
||||
}
|
||||
|
|
|
@ -58,37 +58,6 @@ class AnalysisOptionsErrorCode extends ErrorCode {
|
|||
ErrorType get type => ErrorType.COMPILE_TIME_ERROR;
|
||||
}
|
||||
|
||||
class AnalysisOptionsHintCode extends ErrorCode {
|
||||
/// An error code indicating that the enablePreviewDart2 setting is
|
||||
/// deprecated.
|
||||
static const AnalysisOptionsHintCode PREVIEW_DART_2_SETTING_DEPRECATED =
|
||||
AnalysisOptionsHintCode(
|
||||
'PREVIEW_DART_2_SETTING_DEPRECATED',
|
||||
"The 'enablePreviewDart2' setting is deprecated.",
|
||||
correctionMessage: "It is no longer necessary to explicitly enable Dart 2.",
|
||||
);
|
||||
|
||||
/// Initialize a newly created error code to have the given [name].
|
||||
const AnalysisOptionsHintCode(
|
||||
String name,
|
||||
String problemMessage, {
|
||||
super.correctionMessage,
|
||||
super.hasPublishedDocs = false,
|
||||
super.isUnresolvedIdentifier = false,
|
||||
String? uniqueName,
|
||||
}) : super(
|
||||
name: name,
|
||||
problemMessage: problemMessage,
|
||||
uniqueName: 'AnalysisOptionsHintCode.${uniqueName ?? name}',
|
||||
);
|
||||
|
||||
@override
|
||||
ErrorSeverity get errorSeverity => ErrorSeverity.INFO;
|
||||
|
||||
@override
|
||||
ErrorType get type => ErrorType.HINT;
|
||||
}
|
||||
|
||||
class AnalysisOptionsWarningCode extends ErrorCode {
|
||||
/// An error code indicating a specified include file has a warning.
|
||||
///
|
||||
|
|
|
@ -22,7 +22,6 @@ import 'package:analyzer/src/pubspec/pubspec_warning_code.dart';
|
|||
const List<ErrorCode> errorCodeValues = [
|
||||
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR,
|
||||
AnalysisOptionsErrorCode.PARSE_ERROR,
|
||||
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED,
|
||||
AnalysisOptionsWarningCode.INCLUDED_FILE_WARNING,
|
||||
AnalysisOptionsWarningCode.INCLUDE_FILE_NOT_FOUND,
|
||||
AnalysisOptionsWarningCode.INVALID_OPTION,
|
||||
|
|
|
@ -82,13 +82,6 @@ class DriverOptions {
|
|||
set enableAssertInitializer(bool enable) {
|
||||
// Ignored because the option is now always enabled.
|
||||
}
|
||||
|
||||
/// Whether to use Dart 2.0 features.
|
||||
@deprecated
|
||||
bool get previewDart2 => true;
|
||||
|
||||
@deprecated
|
||||
set previewDart2(bool value) {}
|
||||
}
|
||||
|
||||
class LintDriver {
|
||||
|
|
|
@ -118,7 +118,6 @@ void applyToAnalysisOptions(AnalysisOptionsImpl options, YamlMap optionMap) {
|
|||
/// `analyzer` analysis options constants.
|
||||
class AnalyzerOptions {
|
||||
static const String analyzer = 'analyzer';
|
||||
static const String enablePreviewDart2 = 'enablePreviewDart2';
|
||||
|
||||
static const String cannotIgnore = 'cannot-ignore';
|
||||
static const String codeStyle = 'code-style';
|
||||
|
@ -490,11 +489,7 @@ class LanguageOptionValidator extends OptionsValidator {
|
|||
bool validKey = false;
|
||||
if (k is YamlScalar) {
|
||||
key = k.value?.toString();
|
||||
if (AnalyzerOptions.enablePreviewDart2 == key) {
|
||||
reporter.reportErrorForSpan(
|
||||
AnalysisOptionsHintCode.PREVIEW_DART_2_SETTING_DEPRECATED,
|
||||
k.span);
|
||||
} else if (!AnalyzerOptions.languageOptions.contains(key)) {
|
||||
if (!AnalyzerOptions.languageOptions.contains(key)) {
|
||||
_builder.reportError(reporter, AnalyzerOptions.language, k);
|
||||
} else {
|
||||
// If we have a valid key, go on and check the value.
|
||||
|
|
|
@ -53,13 +53,6 @@ AnalysisOptionsErrorCode:
|
|||
|
||||
Parameters:
|
||||
0: the error message from the parse error
|
||||
AnalysisOptionsHintCode:
|
||||
PREVIEW_DART_2_SETTING_DEPRECATED:
|
||||
problemMessage: "The 'enablePreviewDart2' setting is deprecated."
|
||||
correctionMessage: It is no longer necessary to explicitly enable Dart 2.
|
||||
comment: |-
|
||||
An error code indicating that the enablePreviewDart2 setting is
|
||||
deprecated.
|
||||
AnalysisOptionsWarningCode:
|
||||
INCLUDED_FILE_WARNING:
|
||||
problemMessage: "Warning in the included options file {0}({1}..{2}): {3}"
|
||||
|
|
|
@ -18,11 +18,6 @@ const List<ErrorClassInfo> errorClasses = [
|
|||
name: 'AnalysisOptionsErrorCode',
|
||||
type: 'COMPILE_TIME_ERROR',
|
||||
severity: 'ERROR'),
|
||||
ErrorClassInfo(
|
||||
filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
|
||||
name: 'AnalysisOptionsHintCode',
|
||||
type: 'HINT',
|
||||
severity: 'INFO'),
|
||||
ErrorClassInfo(
|
||||
filePath: 'lib/src/analysis_options/error/option_codes.g.dart',
|
||||
name: 'AnalysisOptionsWarningCode',
|
||||
|
|
Loading…
Reference in a new issue