Skip to content

Commit 814c61d

Browse files
stereotype441Commit Queue
authored andcommitted
[analyzer] Don't import generated error code files more than needed.
This change adds a `@Deprecated` annotation to each of the analyzer's generated error code files, with a deprecation message that says the corresponding non-code-generated file should be imported instead. For example, `package:analyzer/src/error/codes.g.dart` now has a deprecation message saying that `package:analyzer/src/error/codes.dart` should be used instead. All existing imports of these libraries are switched to the corresponding non-code-generated file, where possible. (The only circumstance in which it's not possible is when the corresponding non-code-generated file imports the code-generated file---e.g., when `package:analyzer/src/error/codes.dart` imports `package:analyzer/src/error/codes.g.dart`. In these cases, the deprecation warning is suppressed with an "ignore" comment.) This change is part of a long term effort to unify the analyzer and CFE representations of error messages. It paves the way for a follow-up CL in which I intend to move some of the generated code from `package:analyzer` to `package:_fe_analyzer_shared`, to allow it to be shared with the CFE. Change-Id: Ie91dc8fc9357defa8974cbe6836d582979d87d81 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/437840 Reviewed-by: Konstantin Shcheglov <[email protected]> Reviewed-by: Samuel Rawlins <[email protected]> Commit-Queue: Paul Berry <[email protected]>
1 parent a7e6a9f commit 814c61d

File tree

59 files changed

+181
-71
lines changed

Some content is hidden

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

59 files changed

+181
-71
lines changed

pkg/analysis_server/lib/src/handler/legacy/legacy_handler.dart

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,13 @@
44

55
import 'dart:async';
66

7-
import 'package:_fe_analyzer_shared/src/scanner/errors.dart';
87
import 'package:analysis_server/protocol/protocol.dart';
98
import 'package:analysis_server/protocol/protocol_generated.dart';
109
import 'package:analysis_server/src/legacy_analysis_server.dart';
1110
import 'package:analysis_server/src/protocol/protocol_internal.dart';
1211
import 'package:analyzer/dart/analysis/results.dart';
1312
import 'package:analyzer/diagnostic/diagnostic.dart';
14-
import 'package:analyzer/src/dart/error/syntactic_errors.g.dart';
13+
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
1514
import 'package:analyzer/src/util/performance/operation_performance.dart';
1615
import 'package:analyzer/src/utilities/cancellation.dart';
1716
import 'package:dart_style/dart_style.dart';

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
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:_fe_analyzer_shared/src/scanner/errors.dart';
65
import 'package:analysis_server/protocol/protocol_generated.dart'
76
hide AnalysisOptions;
87
import 'package:analysis_server/src/lsp/error_or.dart';
@@ -32,7 +31,7 @@ import 'package:analyzer/source/error_processor.dart';
3231
import 'package:analyzer/source/file_source.dart';
3332
import 'package:analyzer/source/source.dart';
3433
import 'package:analyzer/source/source_range.dart';
35-
import 'package:analyzer/src/dart/error/syntactic_errors.g.dart';
34+
import 'package:analyzer/src/dart/error/syntactic_errors.dart';
3635
import 'package:analyzer/src/error/codes.dart';
3736
import 'package:analyzer/src/lint/linter.dart';
3837
import 'package:analyzer/src/lint/linter_visitor.dart';

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
@@ -8,7 +8,7 @@ import 'package:analyzer/dart/ast/ast.dart';
88
import 'package:analyzer/dart/ast/token.dart';
99
import 'package:analyzer/diagnostic/diagnostic.dart';
1010
import 'package:analyzer/source/source_range.dart';
11-
import 'package:analyzer/src/error/codes.g.dart';
11+
import 'package:analyzer/src/error/codes.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';

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -260,7 +260,7 @@ import 'package:analysis_server_plugin/src/correction/fix_generators.dart';
260260
import 'package:analysis_server_plugin/src/correction/fix_processor.dart';
261261
import 'package:analysis_server_plugin/src/correction/ignore_diagnostic.dart';
262262
import 'package:analyzer/error/error.dart';
263-
import 'package:analyzer/src/dart/error/ffi_code.g.dart';
263+
import 'package:analyzer/src/dart/error/ffi_code.dart';
264264
import 'package:analyzer/src/error/codes.dart';
265265
import 'package:analyzer/src/generated/parser.dart';
266266
import 'package:linter/src/lint_codes.dart';

pkg/analysis_server/test/abstract_single_unit.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import 'package:analyzer/dart/analysis/results.dart';
66
import 'package:analyzer/dart/ast/ast.dart';
77
import 'package:analyzer/dart/element/element.dart';
88
import 'package:analyzer/file_system/file_system.dart';
9-
import 'package:analyzer/src/error/codes.g.dart';
9+
import 'package:analyzer/src/error/codes.dart';
1010
import 'package:analyzer/src/test_utilities/find_element2.dart';
1111
import 'package:analyzer/src/test_utilities/find_node.dart';
1212
import 'package:analyzer/src/test_utilities/test_code_format.dart';

pkg/analysis_server/test/src/services/correction/fix/remove_name_from_declaration_clause_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:analysis_server/src/services/correction/fix.dart';
6-
import 'package:analyzer/src/dart/error/ffi_code.g.dart';
6+
import 'package:analyzer/src/dart/error/ffi_code.dart';
77
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
88
import 'package:test_reflective_loader/test_reflective_loader.dart';
99

pkg/analysis_server_plugin/test/single_unit.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import 'package:analyzer/file_system/file_system.dart';
88
import 'package:analyzer/src/dart/analysis/analysis_context_collection.dart';
99
import 'package:analyzer/src/dart/analysis/byte_store.dart';
1010
import 'package:analyzer/src/dart/analysis/driver_based_analysis_context.dart';
11-
import 'package:analyzer/src/error/codes.g.dart';
11+
import 'package:analyzer/src/error/codes.dart';
1212
import 'package:analyzer/src/generated/engine.dart' show AnalysisEngine;
1313
import 'package:analyzer/src/test_utilities/find_node.dart';
1414
import 'package:analyzer/src/test_utilities/mock_sdk.dart';

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
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+
// ignore: deprecated_member_use_from_same_package
56
export 'package:analyzer/src/analysis_options/error/option_codes.g.dart';

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@
1616

1717
/// @docImport 'package:analyzer/src/dart/error/syntactic_errors.g.dart';
1818
/// @docImport 'package:analyzer/src/error/inference_error.dart';
19+
@Deprecated(
20+
// This library is deprecated to prevent it from being accidentally imported
21+
// It should only be imported by the corresponding non-code-generated library
22+
// (which suppresses the deprecation warning using an "ignore" comment).
23+
'Use package:analyzer/src/analysis_options/error/option_codes.dart instead',
24+
)
1925
library;
2026

2127
import "package:analyzer/error/error.dart";

pkg/analyzer/lib/src/dart/ast/ast.dart

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ import 'package:analyzer/src/dart/element/type.dart';
3838
import 'package:analyzer/src/dart/element/type_schema.dart';
3939
import 'package:analyzer/src/dart/resolver/body_inference_context.dart';
4040
import 'package:analyzer/src/dart/resolver/typed_literal_resolver.dart';
41-
import 'package:analyzer/src/error/codes.g.dart';
41+
import 'package:analyzer/src/error/codes.dart';
4242
import 'package:analyzer/src/fasta/token_utils.dart' as util show findPrevious;
4343
import 'package:analyzer/src/generated/inference_log.dart';
4444
import 'package:analyzer/src/generated/resolver.dart';

0 commit comments

Comments
 (0)