Skip to content

Commit 701dfa2

Browse files
parloughCommit Queue
authored andcommitted
[linter] Follow-up clean up for lint name and code generation
- Add `.g` suffix to generated filenames and export from the base file. - Rename `linter_lint_codes.dart` to just `lint_codes.dart` for simplicity. - Export `lint_codes.dart` from `src/analyzer.dart` to avoid importing it in every rule file, as they all need it. - Use pre-existing/shared `generateAll` method for generation. - Add some explanatory docs and comments. Bug: #56835 Change-Id: I605e39156bfcc5e3c19a01157426d26300eb877d Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/388058 Reviewed-by: Brian Wilkerson <[email protected]> Auto-Submit: Parker Lougheed <[email protected]> Commit-Queue: Samuel Rawlins <[email protected]> Reviewed-by: Phil Quitslund <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]>
1 parent 88113a2 commit 701dfa2

File tree

256 files changed

+662
-878
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

256 files changed

+662
-878
lines changed

pkg/analysis_server/lib/src/services/correction/dart/add_diagnostic_property_reference.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ import 'package:analyzer_plugin/utilities/assist/assist.dart';
1515
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1616
import 'package:analyzer_plugin/utilities/change_builder/change_builder_dart.dart';
1717
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
18+
import 'package:linter/src/lint_codes.dart';
1819
import 'package:linter/src/lint_names.dart';
19-
import 'package:linter/src/linter_lint_codes.dart';
2020

2121
class AddDiagnosticPropertyReference extends ResolvedCorrectionProducer {
2222
AddDiagnosticPropertyReference({required super.context});

pkg/analysis_server/lib/src/services/correction/dart/remove_comparison.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import 'package:analyzer/src/error/codes.g.dart';
1212
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1313
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
1414
import 'package:analyzer_plugin/utilities/range_factory.dart';
15-
import 'package:linter/src/linter_lint_codes.dart';
15+
import 'package:linter/src/lint_codes.dart';
1616

1717
class RemoveComparison extends ResolvedCorrectionProducer {
1818
@override

pkg/analysis_server/lib/src/services/correction/dart/replace_with_decorated_box.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:analyzer/src/lint/linter.dart';
1111
import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dart';
1212
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
1313
import 'package:analyzer_plugin/utilities/range_factory.dart';
14-
import 'package:linter/src/linter_lint_codes.dart';
14+
import 'package:linter/src/lint_codes.dart';
1515

1616
class ReplaceWithDecoratedBox extends ResolvedCorrectionProducer {
1717
ReplaceWithDecoratedBox({required super.context});

pkg/analysis_server/lib/src/services/correction/fix_internal.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ import 'package:analyzer/error/error.dart';
247247
import 'package:analyzer/src/dart/error/ffi_code.g.dart';
248248
import 'package:analyzer/src/error/codes.dart';
249249
import 'package:analyzer/src/generated/parser.dart';
250-
import 'package:linter/src/linter_lint_codes.dart';
250+
import 'package:linter/src/lint_codes.dart';
251251

252252
final _builtInLintMultiProducers = {
253253
LinterLintCode.comment_references: [

pkg/analyzer/test/generated/error_suppression_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// BSD-style license that can be found in the LICENSE file.
44

55
import 'package:analyzer/src/error/codes.dart';
6-
import 'package:linter/src/linter_lint_codes.dart';
6+
import 'package:linter/src/lint_codes.dart';
77
import 'package:test_reflective_loader/test_reflective_loader.dart';
88

99
import '../src/dart/resolution/context_collection_resolution.dart';

pkg/analyzer/test/src/dart/micro/simple_file_resolver_test.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import 'package:analyzer/src/dart/error/syntactic_errors.dart';
1111
import 'package:analyzer/src/dart/micro/resolve_file.dart';
1212
import 'package:analyzer/src/dart/micro/utils.dart';
1313
import 'package:analyzer/src/error/codes.dart';
14-
import 'package:linter/src/linter_lint_codes.dart';
14+
import 'package:linter/src/lint_codes.dart';
1515
import 'package:test/test.dart';
1616
import 'package:test_reflective_loader/test_reflective_loader.dart';
1717

pkg/linter/lib/src/analyzer.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ export 'package:analyzer/src/lint/util.dart' show FileSpelunker;
3333
export 'package:analyzer/src/utilities/extensions/ast.dart';
3434
export 'package:analyzer/src/workspace/pub.dart' show PubPackage;
3535

36+
export 'lint_codes.dart';
3637
export 'lint_names.dart';
3738

3839
const loggedAnalyzerErrorExitCode = 63;

pkg/linter/lib/src/lint_codes.dart

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
// Copyright (c) 2024, the Dart project authors. Please see the AUTHORS file
2+
// for details. All rights reserved. Use of this source code is governed by a
3+
// BSD-style license that can be found in the LICENSE file.
4+
5+
export 'lint_codes.g.dart' show LinterLintCode;

pkg/linter/lib/src/linter_lint_codes.dart renamed to pkg/linter/lib/src/lint_codes.g.dart

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
// THIS FILE IS GENERATED. DO NOT EDIT.
66
//
77
// Instead modify 'pkg/linter/messages.yaml' and run
8-
// 'dart run pkg/linter/tool/codes/generate.dart' to update.
8+
// 'dart run pkg/linter/tool/generate_lints.dart' to update.
99

1010
// We allow some snake_case and SCREAMING_SNAKE_CASE identifiers in generated
1111
// code, as they match names declared in the source configuration files.
@@ -1954,6 +1954,9 @@ class LinterLintCode extends LintCode {
19541954
hasPublishedDocs: true,
19551955
);
19561956

1957+
/// A lint code that removed lints can specify as their `lintCode`.
1958+
///
1959+
/// Avoid other usages as it should be made unnecessary and removed.
19571960
static const LintCode removed_lint = LinterLintCode(
19581961
'removed_lint',
19591962
'Removed lint.',

0 commit comments

Comments
 (0)