Update the removeConstructorName fix to handle primary constructors
Closes https://github.com/dart-lang/sdk/issues/63072 Change-Id: I3391484a2693b0ec9f520353ac231ee0d9a60c7c Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/494623 Reviewed-by: Samuel Rawlins <srawlins@google.com> Commit-Queue: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
committed by
Commit Queue
parent
0488d33502
commit
f62d10f40c
@@ -35,6 +35,10 @@ class RemoveConstructorName extends ResolvedCorrectionProducer {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addDeletion(range.startStart(dotToken, node.token.next!));
|
||||
});
|
||||
} else if (node is PrimaryConstructorName) {
|
||||
await builder.addDartFileEdit(file, (builder) {
|
||||
builder.addDeletion(range.startStart(node.period, node.name.next!));
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+11
-2
@@ -75,7 +75,16 @@ class RemoveConstructorNameTest extends FixProcessorLintTest {
|
||||
@override
|
||||
String get lintCode => LintNames.unnecessary_constructor_name;
|
||||
|
||||
Future<void> test_constructorDeclaration() async {
|
||||
Future<void> test_declaration_primary() async {
|
||||
await resolveTestCode(r'''
|
||||
class C.new(int x);
|
||||
''');
|
||||
await assertHasFix(r'''
|
||||
class C(int x);
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_declaration_secondary() async {
|
||||
await resolveTestCode(r'''
|
||||
class A {
|
||||
A.new(int x) {
|
||||
@@ -92,7 +101,7 @@ class A {
|
||||
''');
|
||||
}
|
||||
|
||||
Future<void> test_constructorInvocation() async {
|
||||
Future<void> test_invocation() async {
|
||||
await resolveTestCode(r'''
|
||||
class A { }
|
||||
var a = A.new();
|
||||
|
||||
Reference in New Issue
Block a user