[primary contructors] Fix use_declaring_parameters to ignore fields with doc comments.
Closes https://github.com/dart-lang/sdk/issues/63518 Change-Id: I51fb1a07a758e3d94a212537bc5560e66c483982 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/509181 Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
This commit is contained in:
@@ -64,6 +64,7 @@ class _Visitor extends SimpleAstVisitor<void> {
|
||||
var field = parameterElement.field;
|
||||
if (field != null &&
|
||||
(parameterHasNoType || field.type == parameterElement.type)) {
|
||||
if (field.documentationComment != null) return;
|
||||
rule.reportAtToken(parameter.name);
|
||||
}
|
||||
}
|
||||
@@ -87,6 +88,7 @@ class _Visitor extends SimpleAstVisitor<void> {
|
||||
var parameterElement = parameter.declaredFragment?.element;
|
||||
if (parameterElement != null &&
|
||||
assignedField.type == parameterElement.type) {
|
||||
if (assignedField.documentationComment != null) return;
|
||||
rule.reportAtToken(name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,17 @@ class C(int? i) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_field_withComment() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
class C(int i) {
|
||||
/// A comment.
|
||||
final int i;
|
||||
|
||||
this : i = i;
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_fieldFormalParameter_differentType() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
class C(int this.i) {
|
||||
@@ -73,6 +84,15 @@ class C(int this.[!i!]) {
|
||||
''');
|
||||
}
|
||||
|
||||
test_fieldFormalParameter_withComment() async {
|
||||
await assertNoDiagnostics(r'''
|
||||
class C(int this.i) {
|
||||
/// A comment.
|
||||
int i;
|
||||
}
|
||||
''');
|
||||
}
|
||||
|
||||
test_finalPrivateField_requiredPositional() async {
|
||||
await assertDiagnosticsFromMarkdown(r'''
|
||||
class C(int [!i!]) {
|
||||
|
||||
Reference in New Issue
Block a user