From b08eab360c331d41c2bc9d81c4ebe63edc50c1a7 Mon Sep 17 00:00:00 2001 From: Sam Rawlins Date: Mon, 10 Nov 2025 13:25:11 -0800 Subject: [PATCH] DAS plugins: Fix parameter type of registerFixForRule Fixes https://github.com/dart-lang/sdk/issues/61928 Change-Id: Ibdd63ebe9d70217e8699546d916826480bdfd3f6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/460901 Commit-Queue: Samuel Rawlins Reviewed-by: Brian Wilkerson --- pkg/analysis_server_plugin/CHANGELOG.md | 5 +++++ pkg/analysis_server_plugin/api.txt | 5 ++--- pkg/analysis_server_plugin/lib/registry.dart | 2 +- .../lib/src/correction/fix_generators.dart | 5 ++++- pkg/analysis_server_plugin/lib/src/registry.dart | 2 +- pkg/analysis_server_plugin/pubspec.yaml | 2 +- 6 files changed, 14 insertions(+), 7 deletions(-) diff --git a/pkg/analysis_server_plugin/CHANGELOG.md b/pkg/analysis_server_plugin/CHANGELOG.md index b44e0f31ade..8e514d27c0c 100644 --- a/pkg/analysis_server_plugin/CHANGELOG.md +++ b/pkg/analysis_server_plugin/CHANGELOG.md @@ -1,3 +1,8 @@ +## 0.3.5-dev + +- `PluginRegistry.registerFixForRule` now accepts a `DiagnosticCode` (a + supertype of the old parameter type, `LintCode`). + ## 0.3.4 - Require version `9.0.0` of the `analyzer` package. diff --git a/pkg/analysis_server_plugin/api.txt b/pkg/analysis_server_plugin/api.txt index 8796234cdb3..73c99de916a 100644 --- a/pkg/analysis_server_plugin/api.txt +++ b/pkg/analysis_server_plugin/api.txt @@ -147,7 +147,7 @@ package:analysis_server_plugin/registry.dart: PluginRegistry (class extends Object): new (constructor: PluginRegistry Function()) registerAssist (method: void Function(CorrectionProducer Function({required CorrectionProducerContext context}))) - registerFixForRule (method: void Function(LintCode, CorrectionProducer Function({required CorrectionProducerContext context}))) + registerFixForRule (method: void Function(DiagnosticCode, CorrectionProducer Function({required CorrectionProducerContext context}))) registerLintRule (method: void Function(AbstractAnalysisRule)) registerWarningRule (method: void Function(AbstractAnalysisRule)) dart:async: @@ -164,6 +164,7 @@ dart:core: int (referenced) package:_fe_analyzer_shared/src/base/errors.dart: Diagnostic (referenced) + DiagnosticCode (referenced) package:_fe_analyzer_shared/src/scanner/token.dart: Token (referenced) package:analyzer/analysis_rule/analysis_rule.dart: @@ -212,8 +213,6 @@ package:analyzer/src/dart/ast/ast.dart: package:analyzer/src/dart/element/inheritance_manager3.dart: InheritanceManager3 (referenced) Name (referenced) -package:analyzer/src/dart/error/lint_codes.dart: - LintCode (referenced) package:analyzer_plugin/protocol/protocol_common.dart: SourceChange (referenced) package:analyzer_plugin/utilities/assist/assist.dart: diff --git a/pkg/analysis_server_plugin/lib/registry.dart b/pkg/analysis_server_plugin/lib/registry.dart index 256b3ceb4b6..3d7e60c86bb 100644 --- a/pkg/analysis_server_plugin/lib/registry.dart +++ b/pkg/analysis_server_plugin/lib/registry.dart @@ -12,7 +12,7 @@ abstract class PluginRegistry { /// Registers this fix [generator] for the given lint [code] with the /// analyzer's rule registry. - void registerFixForRule(LintCode code, ProducerGenerator generator); + void registerFixForRule(DiagnosticCode code, ProducerGenerator generator); /// Registers this [rule] with the analyzer's rule registry. void registerLintRule(AbstractAnalysisRule rule); diff --git a/pkg/analysis_server_plugin/lib/src/correction/fix_generators.dart b/pkg/analysis_server_plugin/lib/src/correction/fix_generators.dart index 1788d8cddeb..a59c20115f5 100644 --- a/pkg/analysis_server_plugin/lib/src/correction/fix_generators.dart +++ b/pkg/analysis_server_plugin/lib/src/correction/fix_generators.dart @@ -62,7 +62,10 @@ class _RegisteredFixGenerators { /// Associates the given correction producer [generator] with the lint with /// the given [lintCode]. - void registerFixForLint(LintCode lintCode, ProducerGenerator generator) { + void registerFixForLint( + DiagnosticCode lintCode, + ProducerGenerator generator, + ) { lintProducers.putIfAbsent(lintCode, () => []).add(generator); } } diff --git a/pkg/analysis_server_plugin/lib/src/registry.dart b/pkg/analysis_server_plugin/lib/src/registry.dart index 03327a1475e..dbac4b30108 100644 --- a/pkg/analysis_server_plugin/lib/src/registry.dart +++ b/pkg/analysis_server_plugin/lib/src/registry.dart @@ -44,7 +44,7 @@ final class PluginRegistryImpl implements PluginRegistry { } @override - void registerFixForRule(LintCode code, ProducerGenerator generator) { + void registerFixForRule(DiagnosticCode code, ProducerGenerator generator) { var producer = generator(context: StubCorrectionProducerContext.instance); var fixKind = producer.fixKind; if (fixKind == null) { diff --git a/pkg/analysis_server_plugin/pubspec.yaml b/pkg/analysis_server_plugin/pubspec.yaml index 1eccc83004f..53c847927fd 100644 --- a/pkg/analysis_server_plugin/pubspec.yaml +++ b/pkg/analysis_server_plugin/pubspec.yaml @@ -1,6 +1,6 @@ name: analysis_server_plugin description: A framework and support code for building plugins for the analysis server. -version: 0.3.4 +version: 0.3.5-dev repository: https://github.com/dart-lang/sdk/tree/main/pkg/analysis_server_plugin environment: