analyzer: Remove deprecated DiagnosticOrErrorListener and friends

Change-Id: I06d91cd3e10e27afd10056dfac978d918f594c6e
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/464601
Reviewed-by: Konstantin Shcheglov <scheglov@google.com>
Commit-Queue: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Sam Rawlins
2025-11-25 16:12:00 -08:00
committed by Commit Queue
parent caf33365bc
commit 388a92b160
4 changed files with 8 additions and 27 deletions
+4
View File
@@ -14,6 +14,10 @@
* **Breaking Change:** While the deprecated members mentioned above still exist in the AST,
their parent nodes have changed. This means that code relying on specific parent-child
relationships for these nodes might break.
* **Breaking Change:** Remove deprecated `DiagnosticOrErrorListener` and the
`DiagnosticOrErrorListenerExtension` extension.
* **Breaking Change:** Remove deprecated `RecordingDiagnosticListener.onError`
and `BooleanDiagnosticListener.onError` methods.
* Deprecate `LintCode.new`'s `hasPublishedDocs` parameter.
* Add `RemovedAnalysisRule` as the preferred way to represent removed lint
rules. Deprecated `RuleState.removed` (which was the previous way to do so).
+2 -7
View File
@@ -4612,14 +4612,12 @@ package:analyzer/error/listener.dart:
new (constructor: BooleanDiagnosticListener Function())
errorReported (getter: bool)
onDiagnostic (method: void Function(Diagnostic))
onError (method: void Function(Diagnostic), deprecated)
DiagnosticListener (class extends Object implements DiagnosticOrErrorListener):
DiagnosticListener (class extends Object):
nullListener (static getter: DiagnosticListener)
new (constructor: DiagnosticListener Function())
onDiagnostic (method: void Function(Diagnostic))
DiagnosticOrErrorListener (class extends Object, sealed (immediate subtypes: DiagnosticListener), deprecated)
DiagnosticReporter (class extends Object):
new (constructor: DiagnosticReporter Function(DiagnosticOrErrorListener, Source))
new (constructor: DiagnosticReporter Function(DiagnosticListener, Source))
lockLevel (getter: int)
lockLevel= (setter: int)
source (getter: Source)
@@ -4635,9 +4633,6 @@ package:analyzer/error/listener.dart:
new (constructor: RecordingDiagnosticListener Function())
diagnostics (getter: List<Diagnostic>)
onDiagnostic (method: void Function(Diagnostic))
onError (method: void Function(Diagnostic), deprecated)
DiagnosticOrErrorListenerExtension (extension on DiagnosticOrErrorListener):
onDiagnostic (method: void Function(Diagnostic))
ErrorReporter (type alias for DiagnosticReporter, deprecated)
package:analyzer/exception/exception.dart:
AnalysisException (class extends Object implements Exception):
+1 -18
View File
@@ -24,22 +24,15 @@ class BooleanDiagnosticListener implements DiagnosticListener {
void onDiagnostic(Diagnostic diagnostic) {
_diagnosticReported = true;
}
@Deprecated("Call 'onDiagnostic' instead")
void onError(Diagnostic diagnostic) => onDiagnostic(diagnostic);
}
// ignore: deprecated_member_use_from_same_package
abstract class DiagnosticListener implements DiagnosticOrErrorListener {
abstract class DiagnosticListener {
/// A diagnostic listener that ignores diagnostics that are reported to it.
static const DiagnosticListener nullListener = _NullDiagnosticListener();
void onDiagnostic(Diagnostic diagnostic);
}
@Deprecated("Use 'DiagnosticListener' instead")
sealed class DiagnosticOrErrorListener {}
/// A diagnostic listener that records the diagnostics that are reported to it
/// in a way that is appropriate for caching those diagnostic within an
/// analysis context.
@@ -58,9 +51,6 @@ class RecordingDiagnosticListener implements DiagnosticListener {
void onDiagnostic(Diagnostic diagnostic) {
(_diagnostics ??= {}).add(diagnostic);
}
@Deprecated("Call 'onDiagnostic' instead")
void onError(Diagnostic diagnostic) => onDiagnostic(diagnostic);
}
/// A [DiagnosticListener] that ignores everything.
@@ -72,10 +62,3 @@ class _NullDiagnosticListener implements DiagnosticListener {
// Ignore diagnostics.
}
}
// ignore: deprecated_member_use_from_same_package
extension DiagnosticOrErrorListenerExtension on DiagnosticOrErrorListener {
void onDiagnostic(Diagnostic diagnostic) => switch (this) {
DiagnosticListener self => self.onDiagnostic(diagnostic),
};
}
+1 -2
View File
@@ -145,8 +145,7 @@ Expected types: $expectedTypes''');
@AnalyzerPublicApi(message: 'Exported by package:analyzer/error/listener.dart')
class DiagnosticReporter {
/// The diagnostic listener to which diagnostics are reported.
// ignore: deprecated_member_use_from_same_package
final DiagnosticOrErrorListener _diagnosticListener;
final DiagnosticListener _diagnosticListener;
/// The source to be used when reporting diagnostics.
final Source _source;