linter: Rename State to RuleState, and sub-classes
Change-Id: Id74c1a34e0a3154e1720d323bf4002aceb092dd4
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/429160
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
diff --git a/pkg/analysis_server/test/shared/shared_code_actions_fixes_tests.dart b/pkg/analysis_server/test/shared/shared_code_actions_fixes_tests.dart
index 380dbdb..204f8e9 100644
--- a/pkg/analysis_server/test/shared/shared_code_actions_fixes_tests.dart
+++ b/pkg/analysis_server/test/shared/shared_code_actions_fixes_tests.dart
@@ -881,7 +881,7 @@
_DeprecatedCamelCaseTypes()
: super(
name: 'camel_case_types',
- state: State.deprecated(),
+ state: RuleState.deprecated(),
description: '',
);
diff --git a/pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart b/pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart
index 2abfb9a..2a2acc8 100644
--- a/pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart
+++ b/pkg/analysis_server/test/src/services/completion/yaml/analysis_options_generator_test.dart
@@ -313,7 +313,11 @@
);
InternalRule()
- : super(name: 'internal_lint', state: State.internal(), description: '');
+ : super(
+ name: 'internal_lint',
+ state: RuleState.internal(),
+ description: '',
+ );
@override
DiagnosticCode get diagnosticCode => code;
@@ -323,7 +327,7 @@
static const LintCode _code = LintCode('removed_lint', 'Removed rule.');
_RemovedLint()
- : super(name: 'removed_lint', state: State.removed(), description: '');
+ : super(name: 'removed_lint', state: RuleState.removed(), description: '');
@override
DiagnosticCode get diagnosticCode => _code;
diff --git a/pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_lint_test.dart b/pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_lint_test.dart
index c32ebda..216d4e9 100644
--- a/pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_lint_test.dart
+++ b/pkg/analysis_server/test/src/services/correction/fix/analysis_options/remove_lint_test.dart
@@ -27,7 +27,7 @@
: super(
name: 'deprecated_rule',
description: '',
- state: State.deprecated(since: dart2_12),
+ state: RuleState.deprecated(since: dart2_12),
);
@override
@@ -42,7 +42,7 @@
);
RemovedRule()
- : super(name: 'removed_rule', description: '', state: State.removed());
+ : super(name: 'removed_rule', description: '', state: RuleState.removed());
@override
DiagnosticCode get diagnosticCode => code;
diff --git a/pkg/analyzer/lib/src/error/ignore_validator.dart b/pkg/analyzer/lib/src/error/ignore_validator.dart
index eb86567..8695552 100644
--- a/pkg/analyzer/lib/src/error/ignore_validator.dart
+++ b/pkg/analyzer/lib/src/error/ignore_validator.dart
@@ -207,9 +207,9 @@
} else {
var state = rule.state;
var since = state.since.toString();
- if (state is DeprecatedState) {
+ if (state is DeprecatedRuleState) {
// `todo`(pq): implement
- } else if (state is RemovedState) {
+ } else if (state is RemovedRuleState) {
var replacedBy = state.replacedBy;
if (replacedBy != null) {
_errorReporter.atOffset(
diff --git a/pkg/analyzer/lib/src/lint/linter.dart b/pkg/analyzer/lib/src/lint/linter.dart
index 5cf0a38..a68103a 100644
--- a/pkg/analyzer/lib/src/lint/linter.dart
+++ b/pkg/analyzer/lib/src/lint/linter.dart
@@ -21,7 +21,7 @@
export 'package:analyzer/src/lint/linter_visitor.dart' show NodeLintRegistry;
export 'package:analyzer/src/lint/state.dart'
- show dart2_12, dart3, dart3_3, State;
+ show dart2_12, dart3, dart3_3, RuleState;
/// Describes an [AbstractAnalysisRule] which reports diagnostics using exactly
/// one [DiagnosticCode].
@@ -41,13 +41,14 @@
/// Lint name.
final String name;
- /// The state of a lint, and optionally since when the state began.
- final State state;
+ /// The state of this analysis rule, optionally indicating the "version" that
+ /// this state started applying to this rule.
+ final RuleState state;
AbstractAnalysisRule({
required this.name,
required this.description,
- this.state = const State.stable(),
+ this.state = const RuleState.stable(),
});
/// Indicates whether this analysis rule can work with just the parsed
diff --git a/pkg/analyzer/lib/src/lint/options_rule_validator.dart b/pkg/analyzer/lib/src/lint/options_rule_validator.dart
index 24933f7..098184d 100644
--- a/pkg/analyzer/lib/src/lint/options_rule_validator.dart
+++ b/pkg/analyzer/lib/src/lint/options_rule_validator.dart
@@ -39,11 +39,11 @@
.rules
.firstWhereOrNull((rule) => rule.name == value);
- bool isDeprecatedInCurrentSdk(DeprecatedState state) =>
+ bool isDeprecatedInCurrentSdk(DeprecatedRuleState state) =>
currentSdkAllows(state.since);
- bool isRemovedInCurrentSdk(State state) {
- if (state is! RemovedState) return false;
+ bool isRemovedInCurrentSdk(RuleState state) {
+ if (state is! RemovedRuleState) return false;
return currentSdkAllows(state.since);
}
@@ -103,7 +103,7 @@
// includes).
if (sourceIsOptionsForContextRoot) {
var state = rule.state;
- if (state is DeprecatedState && isDeprecatedInCurrentSdk(state)) {
+ if (state is DeprecatedRuleState && isDeprecatedInCurrentSdk(state)) {
var replacedBy = state.replacedBy;
if (replacedBy != null) {
reporter.atSourceSpan(
@@ -120,7 +120,7 @@
}
} else if (isRemovedInCurrentSdk(state)) {
var since = state.since.toString();
- var replacedBy = (state as RemovedState).replacedBy;
+ var replacedBy = (state as RemovedRuleState).replacedBy;
if (replacedBy != null) {
reporter.atSourceSpan(
node.span,
diff --git a/pkg/analyzer/lib/src/lint/state.dart b/pkg/analyzer/lib/src/lint/state.dart
index cf07c00..8b7330d 100644
--- a/pkg/analyzer/lib/src/lint/state.dart
+++ b/pkg/analyzer/lib/src/lint/state.dart
@@ -13,91 +13,91 @@
/// A version describing Dart language version 3.3.0.
final Version dart3_3 = Version(3, 3, 0);
-/// A state that marks a lint as deprecated.
-final class DeprecatedState extends State {
- /// An optional lint name that replaces the rule with this state.
+@Deprecated("Prefer to use 'RuleState'")
+typedef State = RuleState;
+
+/// A state that marks an analysis rule as deprecated.
+final class DeprecatedRuleState extends RuleState {
+ /// The optional name of an analysis rule which replaces the rule with this
+ /// state.
final String? replacedBy;
- /// Initialize a newly created deprecated state with given values.
- const DeprecatedState._({super.since, this.replacedBy});
+ const DeprecatedRuleState._({super.since, this.replacedBy});
@override
String get label => 'deprecated';
}
-/// A state that marks a lint as experimental.
-final class ExperimentalState extends State {
- /// Initialize a newly created experimental state with given values.
- const ExperimentalState._({super.since});
+/// A state that marks an analysis rule as experimental.
+final class ExperimentalRuleState extends RuleState {
+ const ExperimentalRuleState._({super.since});
@override
String get label => 'experimental';
}
-/// A state that marks a lint as for internal (Dart SDK) use only.
-final class InternalState extends State {
- /// Initialize a newly created internal state with given values.
- const InternalState._({super.since});
+/// A state that marks an analysis rule as for internal (Dart SDK) use only.
+final class InternalRuleState extends RuleState {
+ const InternalRuleState._({super.since});
@override
String get label => 'internal';
}
-/// A state that identifies a lint as having been removed.
-final class RemovedState extends State {
+/// A state that identifies an analysis rule as having been removed.
+final class RemovedRuleState extends RuleState {
/// An optional lint name that replaces the rule with this state.
final String? replacedBy;
- /// Initialize a newly created removed state with given values.
- const RemovedState._({super.since, this.replacedBy});
+ const RemovedRuleState._({super.since, this.replacedBy});
@override
String get label => 'removed';
}
-/// A state that marks a lint as stable.
-final class StableState extends State {
- /// Initialize a newly created stable state with given values.
- const StableState._({super.since});
-
- @override
- String get label => 'stable';
-}
-
/// Describes the state of a lint.
-sealed class State {
+sealed class RuleState {
/// An Optional Dart language version that identifies the start of this state.
final Version? since;
/// Initialize a newly created State object.
- const State({this.since});
+ const RuleState({this.since});
/// Initialize a newly created deprecated state with given values.
- const factory State.deprecated({Version? since, String? replacedBy}) =
- DeprecatedState._;
+ const factory RuleState.deprecated({Version? since, String? replacedBy}) =
+ DeprecatedRuleState._;
/// Initialize a newly created experimental state with given values.
- const factory State.experimental({Version? since}) = ExperimentalState._;
+ const factory RuleState.experimental({Version? since}) =
+ ExperimentalRuleState._;
/// Initialize a newly created internal state with given values.
- const factory State.internal({Version? since}) = InternalState._;
+ const factory RuleState.internal({Version? since}) = InternalRuleState._;
/// Initialize a newly created removed state with given values.
- const factory State.removed({Version? since, String? replacedBy}) =
- RemovedState._;
+ const factory RuleState.removed({Version? since, String? replacedBy}) =
+ RemovedRuleState._;
/// Initialize a newly created stable state with given values.
- const factory State.stable({Version? since}) = StableState._;
+ const factory RuleState.stable({Version? since}) = StableRuleState._;
/// A short description, suitable for displaying in documentation or a
/// diagnostic message.
String get label;
}
-extension StateExtension on State {
- bool get isDeprecated => this is DeprecatedState;
- bool get isExperimental => this is ExperimentalState;
- bool get isInternal => this is InternalState;
- bool get isRemoved => this is RemovedState;
- bool get isStable => this is StableState;
+/// A state that marks an analysis rule as stable.
+final class StableRuleState extends RuleState {
+ const StableRuleState._({super.since});
+
+ @override
+ String get label => 'stable';
+}
+
+extension StateExtension on RuleState {
+ bool get isDeprecated => this is DeprecatedRuleState;
+ bool get isExperimental => this is ExperimentalRuleState;
+ bool get isInternal => this is InternalRuleState;
+ bool get isRemoved => this is RemovedRuleState;
+ bool get isStable => this is StableRuleState;
}
diff --git a/pkg/analyzer/test/src/diagnostics/removed_lint_use_test.dart b/pkg/analyzer/test/src/diagnostics/removed_lint_use_test.dart
index 43d457a..3f078d8 100644
--- a/pkg/analyzer/test/src/diagnostics/removed_lint_use_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/removed_lint_use_test.dart
@@ -20,7 +20,7 @@
RemovedLint()
: super(
name: 'removed_lint',
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
description: '',
);
diff --git a/pkg/analyzer/test/src/diagnostics/replaced_lint_use_test.dart b/pkg/analyzer/test/src/diagnostics/replaced_lint_use_test.dart
index 8352311..7e5968a 100644
--- a/pkg/analyzer/test/src/diagnostics/replaced_lint_use_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/replaced_lint_use_test.dart
@@ -20,7 +20,7 @@
RemovedLint()
: super(
name: 'removed_lint',
- state: State.removed(since: dart3, replacedBy: 'replacing_lint'),
+ state: RuleState.removed(since: dart3, replacedBy: 'replacing_lint'),
description: '',
);
@@ -78,7 +78,7 @@
ReplacingLint()
: super(
name: 'replacing_lint',
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
description: '',
);
diff --git a/pkg/analyzer/test/src/options/options_rule_validator_test.dart b/pkg/analyzer/test/src/options/options_rule_validator_test.dart
index dc911db..dae7c8e 100644
--- a/pkg/analyzer/test/src/options/options_rule_validator_test.dart
+++ b/pkg/analyzer/test/src/options/options_rule_validator_test.dart
@@ -23,14 +23,15 @@
}
class DeprecatedLint extends TestLintRule {
- DeprecatedLint() : super(name: 'deprecated_lint', state: State.deprecated());
+ DeprecatedLint()
+ : super(name: 'deprecated_lint', state: RuleState.deprecated());
}
class DeprecatedLintWithReplacement extends TestLintRule {
DeprecatedLintWithReplacement()
: super(
name: 'deprecated_lint_with_replacement',
- state: State.deprecated(replacedBy: 'replacing_lint'),
+ state: RuleState.deprecated(replacedBy: 'replacing_lint'),
);
}
@@ -38,7 +39,7 @@
DeprecatedSince3Lint()
: super(
name: 'deprecated_since_3_lint',
- state: State.deprecated(since: dart3),
+ state: RuleState.deprecated(since: dart3),
);
}
@@ -301,7 +302,7 @@
RemovedIn2_12Lint()
: super(
name: 'removed_in_2_12_lint',
- state: State.removed(since: dart2_12),
+ state: RuleState.removed(since: dart2_12),
);
}
@@ -309,7 +310,7 @@
ReplacedLint()
: super(
name: 'replaced_lint',
- state: State.removed(since: dart3, replacedBy: 'replacing_lint'),
+ state: RuleState.removed(since: dart3, replacedBy: 'replacing_lint'),
);
}
@@ -332,7 +333,7 @@
}
class StableLint extends TestLintRule {
- StableLint() : super(name: 'stable_lint', state: State.stable());
+ StableLint() : super(name: 'stable_lint', state: RuleState.stable());
}
abstract class TestLintRule extends LintRule {
diff --git a/pkg/linter/lib/src/analyzer.dart b/pkg/linter/lib/src/analyzer.dart
index 6264ba3..f37ce5c 100644
--- a/pkg/linter/lib/src/analyzer.dart
+++ b/pkg/linter/lib/src/analyzer.dart
@@ -18,8 +18,7 @@
LintRule,
LinterContext,
MultiAnalysisRule,
- NodeLintRegistry,
- State;
+ NodeLintRegistry;
export 'package:analyzer/src/lint/pub.dart' show PSEntry, PubspecVisitor;
export 'package:analyzer/src/utilities/extensions/ast.dart';
export 'package:analyzer/src/workspace/pub.dart' show PubPackage;
diff --git a/pkg/linter/lib/src/rules/always_require_non_null_named_parameters.dart b/pkg/linter/lib/src/rules/always_require_non_null_named_parameters.dart
index 84797fe..1a75d60 100644
--- a/pkg/linter/lib/src/rules/always_require_non_null_named_parameters.dart
+++ b/pkg/linter/lib/src/rules/always_require_non_null_named_parameters.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.always_require_non_null_named_parameters,
description: _desc,
- state: State.removed(since: dart3_3),
+ state: RuleState.removed(since: dart3_3),
);
@override
diff --git a/pkg/linter/lib/src/rules/analyzer_public_api.dart b/pkg/linter/lib/src/rules/analyzer_public_api.dart
index 42ea9d8..0d04180 100644
--- a/pkg/linter/lib/src/rules/analyzer_public_api.dart
+++ b/pkg/linter/lib/src/rules/analyzer_public_api.dart
@@ -8,6 +8,7 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -87,7 +88,11 @@
);
AnalyzerPublicApi()
- : super(name: ruleName, description: _desc, state: const State.internal());
+ : super(
+ name: ruleName,
+ description: _desc,
+ state: const RuleState.internal(),
+ );
@override
List<DiagnosticCode> get diagnosticCodes => [
diff --git a/pkg/linter/lib/src/rules/annotate_redeclares.dart b/pkg/linter/lib/src/rules/annotate_redeclares.dart
index 29fa509..0dbdca9 100644
--- a/pkg/linter/lib/src/rules/annotate_redeclares.dart
+++ b/pkg/linter/lib/src/rules/annotate_redeclares.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -16,7 +17,7 @@
: super(
name: LintNames.annotate_redeclares,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/avoid_as.dart b/pkg/linter/lib/src/rules/avoid_as.dart
index 221dd71..de162a8 100644
--- a/pkg/linter/lib/src/rules/avoid_as.dart
+++ b/pkg/linter/lib/src/rules/avoid_as.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.avoid_as,
description: _desc,
- state: State.removed(since: dart2_12),
+ state: RuleState.removed(since: dart2_12),
);
@override
diff --git a/pkg/linter/lib/src/rules/avoid_futureor_void.dart b/pkg/linter/lib/src/rules/avoid_futureor_void.dart
index e176152..2feb197 100644
--- a/pkg/linter/lib/src/rules/avoid_futureor_void.dart
+++ b/pkg/linter/lib/src/rules/avoid_futureor_void.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../util/variance_checker.dart';
@@ -17,7 +18,7 @@
: super(
name: LintNames.avoid_futureor_void,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/avoid_returning_null.dart b/pkg/linter/lib/src/rules/avoid_returning_null.dart
index 27864ab..c67dcf3 100644
--- a/pkg/linter/lib/src/rules/avoid_returning_null.dart
+++ b/pkg/linter/lib/src/rules/avoid_returning_null.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -15,7 +16,7 @@
: super(
name: LintNames.avoid_returning_null,
description: _desc,
- state: State.removed(since: dart3_3),
+ state: RuleState.removed(since: dart3_3),
);
@override
diff --git a/pkg/linter/lib/src/rules/avoid_returning_null_for_future.dart b/pkg/linter/lib/src/rules/avoid_returning_null_for_future.dart
index 6ac253f..d7dff2f 100644
--- a/pkg/linter/lib/src/rules/avoid_returning_null_for_future.dart
+++ b/pkg/linter/lib/src/rules/avoid_returning_null_for_future.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.avoid_returning_null_for_future,
description: _desc,
- state: State.removed(since: dart3_3),
+ state: RuleState.removed(since: dart3_3),
);
@override
diff --git a/pkg/linter/lib/src/rules/avoid_unstable_final_fields.dart b/pkg/linter/lib/src/rules/avoid_unstable_final_fields.dart
index fc9346b..6369485 100644
--- a/pkg/linter/lib/src/rules/avoid_unstable_final_fields.dart
+++ b/pkg/linter/lib/src/rules/avoid_unstable_final_fields.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -15,7 +16,7 @@
: super(
name: LintNames.avoid_unstable_final_fields,
description: _desc,
- state: const State.removed(),
+ state: const RuleState.removed(),
);
@override
diff --git a/pkg/linter/lib/src/rules/enable_null_safety.dart b/pkg/linter/lib/src/rules/enable_null_safety.dart
index c0f015a..a87179c 100644
--- a/pkg/linter/lib/src/rules/enable_null_safety.dart
+++ b/pkg/linter/lib/src/rules/enable_null_safety.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.enable_null_safety,
description: _desc,
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
);
@override
diff --git a/pkg/linter/lib/src/rules/erase_dart_type_extension_types.dart b/pkg/linter/lib/src/rules/erase_dart_type_extension_types.dart
index a15ed7f..fb4c995 100644
--- a/pkg/linter/lib/src/rules/erase_dart_type_extension_types.dart
+++ b/pkg/linter/lib/src/rules/erase_dart_type_extension_types.dart
@@ -5,6 +5,7 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../extensions.dart';
@@ -17,7 +18,7 @@
: super(
name: LintNames.erase_dart_type_extension_types,
description: _desc,
- state: const State.internal(),
+ state: const RuleState.internal(),
);
@override
diff --git a/pkg/linter/lib/src/rules/implicit_reopen.dart b/pkg/linter/lib/src/rules/implicit_reopen.dart
index 4c38617..95ce5dd 100644
--- a/pkg/linter/lib/src/rules/implicit_reopen.dart
+++ b/pkg/linter/lib/src/rules/implicit_reopen.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -16,7 +17,7 @@
: super(
name: LintNames.implicit_reopen,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/invalid_case_patterns.dart b/pkg/linter/lib/src/rules/invalid_case_patterns.dart
index 3a3f93c..58e6487 100644
--- a/pkg/linter/lib/src/rules/invalid_case_patterns.dart
+++ b/pkg/linter/lib/src/rules/invalid_case_patterns.dart
@@ -8,6 +8,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/error/error.dart';
import 'package:analyzer/src/dart/ast/token.dart'; // ignore: implementation_imports
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -18,7 +19,7 @@
: super(
name: LintNames.invalid_case_patterns,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
// TODO(pq): update to add specific messages w/ specific corrections
diff --git a/pkg/linter/lib/src/rules/invariant_booleans.dart b/pkg/linter/lib/src/rules/invariant_booleans.dart
index e9a2a30..65420b7 100644
--- a/pkg/linter/lib/src/rules/invariant_booleans.dart
+++ b/pkg/linter/lib/src/rules/invariant_booleans.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -14,7 +15,7 @@
: super(
name: LintNames.invariant_booleans,
description: _desc,
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
);
@override
diff --git a/pkg/linter/lib/src/rules/iterable_contains_unrelated_type.dart b/pkg/linter/lib/src/rules/iterable_contains_unrelated_type.dart
index d53b58a..1892519 100644
--- a/pkg/linter/lib/src/rules/iterable_contains_unrelated_type.dart
+++ b/pkg/linter/lib/src/rules/iterable_contains_unrelated_type.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -15,7 +16,7 @@
: super(
name: LintNames.iterable_contains_unrelated_type,
description: _desc,
- state: State.removed(since: dart3_3),
+ state: RuleState.removed(since: dart3_3),
);
@override
diff --git a/pkg/linter/lib/src/rules/list_remove_unrelated_type.dart b/pkg/linter/lib/src/rules/list_remove_unrelated_type.dart
index df9c161..78b88ae 100644
--- a/pkg/linter/lib/src/rules/list_remove_unrelated_type.dart
+++ b/pkg/linter/lib/src/rules/list_remove_unrelated_type.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.list_remove_unrelated_type,
description: _desc,
- state: State.removed(since: dart3_3),
+ state: RuleState.removed(since: dart3_3),
);
@override
diff --git a/pkg/linter/lib/src/rules/no_default_cases.dart b/pkg/linter/lib/src/rules/no_default_cases.dart
index 0d53faa..d81da22 100644
--- a/pkg/linter/lib/src/rules/no_default_cases.dart
+++ b/pkg/linter/lib/src/rules/no_default_cases.dart
@@ -7,6 +7,7 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../extensions.dart';
@@ -18,7 +19,7 @@
: super(
name: LintNames.no_default_cases,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/omit_obvious_local_variable_types.dart b/pkg/linter/lib/src/rules/omit_obvious_local_variable_types.dart
index a15c630..d23a9c8 100644
--- a/pkg/linter/lib/src/rules/omit_obvious_local_variable_types.dart
+++ b/pkg/linter/lib/src/rules/omit_obvious_local_variable_types.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../util/obvious_types.dart';
@@ -17,7 +18,7 @@
: super(
name: LintNames.omit_obvious_local_variable_types,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/omit_obvious_property_types.dart b/pkg/linter/lib/src/rules/omit_obvious_property_types.dart
index 9137677..2cf259f 100644
--- a/pkg/linter/lib/src/rules/omit_obvious_property_types.dart
+++ b/pkg/linter/lib/src/rules/omit_obvious_property_types.dart
@@ -5,6 +5,7 @@
import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../util/obvious_types.dart';
@@ -17,7 +18,7 @@
: super(
name: 'omit_obvious_property_types',
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/package_api_docs.dart b/pkg/linter/lib/src/rules/package_api_docs.dart
index 35b7505..8ea587e 100644
--- a/pkg/linter/lib/src/rules/package_api_docs.dart
+++ b/pkg/linter/lib/src/rules/package_api_docs.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import 'package:pub_semver/pub_semver.dart';
import '../analyzer.dart';
@@ -12,7 +13,7 @@
: super(
name: LintNames.package_api_docs,
description: r'Provide doc comments for all public APIs.',
- state: State.removed(since: Version(3, 7, 0)),
+ state: RuleState.removed(since: Version(3, 7, 0)),
);
@override
diff --git a/pkg/linter/lib/src/rules/prefer_bool_in_asserts.dart b/pkg/linter/lib/src/rules/prefer_bool_in_asserts.dart
index 2352623..ef1bd30 100644
--- a/pkg/linter/lib/src/rules/prefer_bool_in_asserts.dart
+++ b/pkg/linter/lib/src/rules/prefer_bool_in_asserts.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.prefer_bool_in_asserts,
description: _desc,
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
);
@override
diff --git a/pkg/linter/lib/src/rules/prefer_equal_for_default_values.dart b/pkg/linter/lib/src/rules/prefer_equal_for_default_values.dart
index 541136a..4c469522 100644
--- a/pkg/linter/lib/src/rules/prefer_equal_for_default_values.dart
+++ b/pkg/linter/lib/src/rules/prefer_equal_for_default_values.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -13,7 +14,7 @@
: super(
name: LintNames.prefer_equal_for_default_values,
description: _desc,
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
);
@override
diff --git a/pkg/linter/lib/src/rules/specify_nonobvious_local_variable_types.dart b/pkg/linter/lib/src/rules/specify_nonobvious_local_variable_types.dart
index 97fc880..312aa16 100644
--- a/pkg/linter/lib/src/rules/specify_nonobvious_local_variable_types.dart
+++ b/pkg/linter/lib/src/rules/specify_nonobvious_local_variable_types.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../util/obvious_types.dart';
@@ -17,7 +18,7 @@
: super(
name: LintNames.specify_nonobvious_local_variable_types,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/specify_nonobvious_property_types.dart b/pkg/linter/lib/src/rules/specify_nonobvious_property_types.dart
index 5b0d6c1..43adb86 100644
--- a/pkg/linter/lib/src/rules/specify_nonobvious_property_types.dart
+++ b/pkg/linter/lib/src/rules/specify_nonobvious_property_types.dart
@@ -6,6 +6,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../util/obvious_types.dart';
@@ -18,7 +19,7 @@
: super(
name: LintNames.specify_nonobvious_property_types,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/super_goes_last.dart b/pkg/linter/lib/src/rules/super_goes_last.dart
index 5c3d121..433bb94 100644
--- a/pkg/linter/lib/src/rules/super_goes_last.dart
+++ b/pkg/linter/lib/src/rules/super_goes_last.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -14,7 +15,7 @@
: super(
name: LintNames.super_goes_last,
description: _desc,
- state: State.removed(since: dart3),
+ state: RuleState.removed(since: dart3),
);
@override
diff --git a/pkg/linter/lib/src/rules/unnecessary_async.dart b/pkg/linter/lib/src/rules/unnecessary_async.dart
index d7a9335..335d314 100644
--- a/pkg/linter/lib/src/rules/unnecessary_async.dart
+++ b/pkg/linter/lib/src/rules/unnecessary_async.dart
@@ -7,8 +7,8 @@
import 'package:analyzer/dart/element/nullability_suffix.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
-// ignore: implementation_imports
-import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/dart/ast/ast.dart'; // ignore: implementation_imports
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -19,7 +19,7 @@
: super(
name: LintNames.unnecessary_async,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/unnecessary_null_checks.dart b/pkg/linter/lib/src/rules/unnecessary_null_checks.dart
index 9418de3..4954a7d 100644
--- a/pkg/linter/lib/src/rules/unnecessary_null_checks.dart
+++ b/pkg/linter/lib/src/rules/unnecessary_null_checks.dart
@@ -7,6 +7,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -139,7 +140,7 @@
: super(
name: LintNames.unnecessary_null_checks,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/unreachable_from_main.dart b/pkg/linter/lib/src/rules/unreachable_from_main.dart
index 0dcb0ed..839a1a3 100644
--- a/pkg/linter/lib/src/rules/unreachable_from_main.dart
+++ b/pkg/linter/lib/src/rules/unreachable_from_main.dart
@@ -4,12 +4,12 @@
import 'dart:collection';
+import 'package:analyzer/dart/ast/ast.dart';
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
-// ignore: implementation_imports
-import 'package:analyzer/src/dart/ast/ast.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import 'package:collection/collection.dart';
import 'package:pub_semver/pub_semver.dart';
@@ -23,7 +23,7 @@
: super(
name: LintNames.unreachable_from_main,
description: _desc,
- state: State.stable(since: Version(3, 1, 0)),
+ state: RuleState.stable(since: Version(3, 1, 0)),
);
@override
diff --git a/pkg/linter/lib/src/rules/unsafe_html.dart b/pkg/linter/lib/src/rules/unsafe_html.dart
index 483fbf0..7d7a87b 100644
--- a/pkg/linter/lib/src/rules/unsafe_html.dart
+++ b/pkg/linter/lib/src/rules/unsafe_html.dart
@@ -3,6 +3,7 @@
// BSD-style license that can be found in the LICENSE file.
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import 'package:pub_semver/pub_semver.dart';
import '../analyzer.dart';
@@ -12,7 +13,7 @@
: super(
name: LintNames.unsafe_html,
description: 'Avoid unsafe HTML APIs.',
- state: State.removed(since: Version(3, 7, 0)),
+ state: RuleState.removed(since: Version(3, 7, 0)),
);
@override
diff --git a/pkg/linter/lib/src/rules/unsafe_variance.dart b/pkg/linter/lib/src/rules/unsafe_variance.dart
index 8d184d3..91f1a81 100644
--- a/pkg/linter/lib/src/rules/unsafe_variance.dart
+++ b/pkg/linter/lib/src/rules/unsafe_variance.dart
@@ -7,9 +7,9 @@
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/dart/element/type.dart';
import 'package:analyzer/error/error.dart';
-// ignore: implementation_imports
-import 'package:analyzer/src/dart/element/element.dart'
+import 'package:analyzer/src/dart/element/element.dart' // ignore: implementation_imports
show TypeParameterElementImpl2;
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import '../analyzer.dart';
import '../util/variance_checker.dart';
@@ -21,7 +21,7 @@
: super(
name: LintNames.unsafe_variance,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/use_build_context_synchronously.dart b/pkg/linter/lib/src/rules/use_build_context_synchronously.dart
index eaf0102..6a366de 100644
--- a/pkg/linter/lib/src/rules/use_build_context_synchronously.dart
+++ b/pkg/linter/lib/src/rules/use_build_context_synchronously.dart
@@ -7,10 +7,9 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
-// ignore: implementation_imports
-import 'package:analyzer/src/dart/resolver/exit_detector.dart';
-// ignore: implementation_imports
-import 'package:analyzer/src/lint/constants.dart';
+import 'package:analyzer/src/dart/resolver/exit_detector.dart'; // ignore: implementation_imports
+import 'package:analyzer/src/lint/constants.dart'; // ignore: implementation_imports
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import 'package:collection/collection.dart';
import 'package:meta/meta.dart';
import 'package:pub_semver/pub_semver.dart';
@@ -924,7 +923,7 @@
: super(
name: LintNames.use_build_context_synchronously,
description: _desc,
- state: State.stable(since: Version(3, 2, 0)),
+ state: RuleState.stable(since: Version(3, 2, 0)),
);
@override
diff --git a/pkg/linter/lib/src/rules/use_late_for_private_fields_and_variables.dart b/pkg/linter/lib/src/rules/use_late_for_private_fields_and_variables.dart
index fe66194..3fdc61e 100644
--- a/pkg/linter/lib/src/rules/use_late_for_private_fields_and_variables.dart
+++ b/pkg/linter/lib/src/rules/use_late_for_private_fields_and_variables.dart
@@ -7,6 +7,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import 'package:collection/collection.dart';
import '../analyzer.dart';
@@ -27,7 +28,7 @@
: super(
name: LintNames.use_late_for_private_fields_and_variables,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/lib/src/rules/use_super_parameters.dart b/pkg/linter/lib/src/rules/use_super_parameters.dart
index 034203f..bb81efa 100644
--- a/pkg/linter/lib/src/rules/use_super_parameters.dart
+++ b/pkg/linter/lib/src/rules/use_super_parameters.dart
@@ -7,6 +7,7 @@
import 'package:analyzer/dart/ast/visitor.dart';
import 'package:analyzer/dart/element/element.dart';
import 'package:analyzer/error/error.dart';
+import 'package:analyzer/src/lint/linter.dart'; // ignore: implementation_imports
import 'package:analyzer/src/utilities/extensions/string.dart'; // ignore: implementation_imports
import '../analyzer.dart';
@@ -28,7 +29,7 @@
: super(
name: LintNames.use_super_parameters,
description: _desc,
- state: const State.experimental(),
+ state: const RuleState.experimental(),
);
@override
diff --git a/pkg/linter/tool/messages_info.dart b/pkg/linter/tool/messages_info.dart
index 080e1da..3493385 100644
--- a/pkg/linter/tool/messages_info.dart
+++ b/pkg/linter/tool/messages_info.dart
@@ -96,7 +96,7 @@
class RuleInfo {
final String name;
final List<CodeInfo> codes;
- final List<State> states;
+ final List<RuleState> states;
final Set<String> categories;
final bool hasPublishedDocs;
final String? documentation;
@@ -372,7 +372,7 @@
return codeInfos;
}
- List<State> _validateStates() {
+ List<RuleState> _validateStates() {
var states = _stateEntries;
if (states == null || states.isEmpty) {
throw StateError('Tried to build a RuleInfo without a state added!');
@@ -381,11 +381,11 @@
var sortedStates = states
.map(
(state) => switch (state.name) {
- 'experimental' => State.experimental(since: state.version),
- 'stable' => State.stable(since: state.version),
- 'internal' => State.internal(since: state.version),
- 'deprecated' => State.deprecated(since: state.version),
- 'removed' => State.removed(since: state.version),
+ 'experimental' => RuleState.experimental(since: state.version),
+ 'stable' => RuleState.stable(since: state.version),
+ 'internal' => RuleState.internal(since: state.version),
+ 'deprecated' => RuleState.deprecated(since: state.version),
+ 'removed' => RuleState.removed(since: state.version),
_ => _throwLintError('Unexpected state name: ${state.name}.'),
},
)