mirror of
https://github.com/dart-lang/sdk
synced 2024-10-14 11:53:55 +00:00
quick fix for EMPTY_RECORD_TYPE_WITH_COMMA
(Also improves fix description for `EMPTY_RECORD_LITERAL_WITH_COMMA`.) See: https://github.com/dart-lang/sdk/issues/55917 Change-Id: I742506d8c1a77b10f99861aa84947f8d348916df Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/371342 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com> Auto-Submit: Phil Quitslund <pquitslund@google.com> Commit-Queue: Phil Quitslund <pquitslund@google.com>
This commit is contained in:
parent
92b744d1b2
commit
9e51c2fa74
|
@ -9,7 +9,15 @@ import 'package:analyzer_plugin/utilities/change_builder/change_builder_core.dar
|
|||
import 'package:analyzer_plugin/utilities/fixes/fixes.dart';
|
||||
|
||||
class RemoveComma extends ResolvedCorrectionProducer {
|
||||
RemoveComma({required super.context});
|
||||
final String targetDescription;
|
||||
|
||||
RemoveComma.emptyRecordLiteral({required CorrectionProducerContext context})
|
||||
: this._(context: context, targetDescription: 'empty record literals');
|
||||
|
||||
RemoveComma.emptyRecordType({required CorrectionProducerContext context})
|
||||
: this._(context: context, targetDescription: 'empty record types');
|
||||
|
||||
RemoveComma._({required super.context, required this.targetDescription});
|
||||
|
||||
@override
|
||||
CorrectionApplicability get applicability =>
|
||||
|
@ -18,6 +26,9 @@ class RemoveComma extends ResolvedCorrectionProducer {
|
|||
@override
|
||||
FixKind get fixKind => DartFixKind.REMOVE_COMMA;
|
||||
|
||||
@override
|
||||
List<String>? get multiFixArguments => [targetDescription];
|
||||
|
||||
@override
|
||||
FixKind get multiFixKind => DartFixKind.REMOVE_COMMA_MULTI;
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@
|
|||
#
|
||||
# Stats:
|
||||
# - 42 "needsEvaluation"
|
||||
# - 324 "needsFix"
|
||||
# - 423 "hasFix"
|
||||
# - 323 "needsFix"
|
||||
# - 424 "hasFix"
|
||||
# - 517 "noFix"
|
||||
|
||||
AnalysisOptionsErrorCode.INCLUDED_FILE_PARSE_ERROR:
|
||||
|
@ -2646,17 +2646,13 @@ ParserErrorCode.EMPTY_ENUM_BODY:
|
|||
added.
|
||||
ParserErrorCode.EMPTY_RECORD_LITERAL_WITH_COMMA:
|
||||
status: hasFix
|
||||
notes: |-
|
||||
Remove the comma.
|
||||
ParserErrorCode.EMPTY_RECORD_TYPE_NAMED_FIELDS_LIST:
|
||||
status: noFix
|
||||
notes: |-
|
||||
It's likely that the user just hasn't provided a named field yet, and
|
||||
offering to remove the braces would be counter-productive.
|
||||
ParserErrorCode.EMPTY_RECORD_TYPE_WITH_COMMA:
|
||||
status: needsFix
|
||||
notes: |-
|
||||
Remove the comma.
|
||||
status: hasFix
|
||||
ParserErrorCode.ENUM_IN_CLASS:
|
||||
status: needsFix
|
||||
notes: |-
|
||||
|
|
|
@ -1026,7 +1026,7 @@ class DartFixKind {
|
|||
static const REMOVE_COMMA_MULTI = FixKind(
|
||||
'dart.fix.remove.comma.multi',
|
||||
DartFixKindPriority.IN_FILE,
|
||||
'Remove commas everywhere in file',
|
||||
'Remove commas from {0} everywhere in file',
|
||||
);
|
||||
static const REMOVE_COMPARISON = FixKind(
|
||||
'dart.fix.remove.comparison',
|
||||
|
|
|
@ -1388,7 +1388,10 @@ final _builtInNonLintProducers = <ErrorCode, List<ProducerGenerator>>{
|
|||
RemoveLexeme.modifier,
|
||||
],
|
||||
ParserErrorCode.EMPTY_RECORD_LITERAL_WITH_COMMA: [
|
||||
RemoveComma.new,
|
||||
RemoveComma.emptyRecordLiteral,
|
||||
],
|
||||
ParserErrorCode.EMPTY_RECORD_TYPE_WITH_COMMA: [
|
||||
RemoveComma.emptyRecordType,
|
||||
],
|
||||
ParserErrorCode.EXPECTED_TOKEN: [
|
||||
InsertSemicolon.new,
|
||||
|
|
|
@ -48,6 +48,15 @@ f() {
|
|||
f() {
|
||||
();
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_emptyRecordType() async {
|
||||
await resolveTestCode('''
|
||||
(,)? f() => null;
|
||||
''');
|
||||
await assertHasFix('''
|
||||
()? f() => null;
|
||||
''');
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue