Inline SingleCorrectionProducer into CorrectionProducer.

It does not look to be used for anything else.

Change-Id: Iba283b93a84c2d1fe81685c07c8e81350759a48b
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/308521
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-06-12 16:11:18 +00:00 committed by Commit Queue
parent 524cf849b2
commit ed85426591

View file

@ -34,10 +34,62 @@ import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
import 'package:analyzer_plugin/utilities/range_factory.dart';
/// An object that can compute a correction (fix or assist) in a Dart file.
abstract class CorrectionProducer extends SingleCorrectionProducer {
abstract class CorrectionProducer extends _AbstractCorrectionProducer {
/// Return the arguments that should be used when composing the message for an
/// assist, or `null` if the assist message has no parameters or if this
/// producer doesn't support assists.
List<Object>? get assistArguments => null;
/// Return the assist kind that should be used to build an assist, or `null`
/// if this producer doesn't support assists.
AssistKind? get assistKind => null;
/// Return `true` if this producer can be used to fix diagnostics across
/// multiple files. Cases where this will return `false` include fixes for
/// which
/// - the modified regions can overlap, and
/// - fixes that have not been tested to ensure that they can be used this
/// way.
bool get canBeAppliedInBulk => false;
/// Return `true` if this producer can be used to fix multiple diagnostics in
/// the same file. Cases where this will return `false` include fixes for
/// which
/// - the modified regions can overlap,
/// - the fix for one diagnostic would fix all diagnostics with the same code,
/// and,
/// - fixes that have not been tested to ensure that they can be used this
/// way.
///
/// Producers that return `true` should return non-null values from both
/// [multiFixKind] and [multiFixArguments].
bool get canBeAppliedToFile => false;
/// Return the type for the class `bool` from `dart:core`.
DartType get coreTypeBool => resolvedResult.typeProvider.boolType;
/// Return the length of the error message being fixed, or `null` if there is
/// no diagnostic.
int? get errorLength => diagnostic?.problemMessage.length;
/// Return the text of the error message being fixed, or `null` if there is
/// no diagnostic.
String? get errorMessage =>
diagnostic?.problemMessage.messageText(includeUrl: true);
/// Return the offset of the error message being fixed, or `null` if there is
/// no diagnostic.
int? get errorOffset => diagnostic?.problemMessage.offset;
/// Return the arguments that should be used when composing the message for a
/// fix, or `null` if the fix message has no parameters or if this producer
/// doesn't support fixes.
List<Object>? get fixArguments => null;
/// Return the fix kind that should be used to build a fix, or `null` if this
/// producer doesn't support fixes.
FixKind? get fixKind => null;
/// Returns `true` if [node] is in a static context.
bool get inStaticContext {
// constructor initializer cannot reference "this"
@ -54,6 +106,15 @@ abstract class CorrectionProducer extends SingleCorrectionProducer {
return method != null && method.isStatic;
}
/// Return the arguments that should be used when composing the message for a
/// multi-fix, or `null` if the fix message has no parameters or if this
/// producer doesn't support multi-fixes.
List<Object>? get multiFixArguments => null;
/// Return the fix kind that should be used to build a multi-fix, or `null` if
/// this producer doesn't support multi-fixes.
FixKind? get multiFixKind => null;
Future<void> compute(ChangeBuilder builder);
/// Return the class for the given [element].
@ -345,70 +406,6 @@ abstract class MultiCorrectionProducer extends _AbstractCorrectionProducer {
Future<List<CorrectionProducer>> get producers;
}
/// An object that can compute a correction (fix or assist) in a Dart file.
abstract class SingleCorrectionProducer extends _AbstractCorrectionProducer {
/// Return the arguments that should be used when composing the message for an
/// assist, or `null` if the assist message has no parameters or if this
/// producer doesn't support assists.
List<Object>? get assistArguments => null;
/// Return the assist kind that should be used to build an assist, or `null`
/// if this producer doesn't support assists.
AssistKind? get assistKind => null;
/// Return `true` if this producer can be used to fix diagnostics across
/// multiple files. Cases where this will return `false` include fixes for
/// which
/// - the modified regions can overlap, and
/// - fixes that have not been tested to ensure that they can be used this
/// way.
bool get canBeAppliedInBulk => false;
/// Return `true` if this producer can be used to fix multiple diagnostics in
/// the same file. Cases where this will return `false` include fixes for
/// which
/// - the modified regions can overlap,
/// - the fix for one diagnostic would fix all diagnostics with the same code,
/// and,
/// - fixes that have not been tested to ensure that they can be used this
/// way.
///
/// Producers that return `true` should return non-null values from both
/// [multiFixKind] and [multiFixArguments].
bool get canBeAppliedToFile => false;
/// Return the length of the error message being fixed, or `null` if there is
/// no diagnostic.
int? get errorLength => diagnostic?.problemMessage.length;
/// Return the text of the error message being fixed, or `null` if there is
/// no diagnostic.
String? get errorMessage =>
diagnostic?.problemMessage.messageText(includeUrl: true);
/// Return the offset of the error message being fixed, or `null` if there is
/// no diagnostic.
int? get errorOffset => diagnostic?.problemMessage.offset;
/// Return the arguments that should be used when composing the message for a
/// fix, or `null` if the fix message has no parameters or if this producer
/// doesn't support fixes.
List<Object>? get fixArguments => null;
/// Return the fix kind that should be used to build a fix, or `null` if this
/// producer doesn't support fixes.
FixKind? get fixKind => null;
/// Return the arguments that should be used when composing the message for a
/// multi-fix, or `null` if the fix message has no parameters or if this
/// producer doesn't support multi-fixes.
List<Object>? get multiFixArguments => null;
/// Return the fix kind that should be used to build a multi-fix, or `null` if
/// this producer doesn't support multi-fixes.
FixKind? get multiFixKind => null;
}
/// The behavior shared by [CorrectionProducer] and [MultiCorrectionProducer].
abstract class _AbstractCorrectionProducer {
/// The context used to produce corrections.