Skip to content

Commit 1770e1a

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate matching_super_parameters
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: I39c000f58ee8203d5473c6d0d6f9bacaa2c1a851 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/391564 Auto-Submit: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]> Commit-Queue: Brian Wilkerson <[email protected]>
1 parent ea5fdaa commit 1770e1a

File tree

2 files changed

+11
-10
lines changed

2 files changed

+11
-10
lines changed

pkg/linter/analyzer_use_new_elements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ lib/src/rules/library_private_types_in_public_api.dart
8686
lib/src/rules/lines_longer_than_80_chars.dart
8787
lib/src/rules/list_remove_unrelated_type.dart
8888
lib/src/rules/literal_only_boolean_expressions.dart
89+
lib/src/rules/matching_super_parameters.dart
8990
lib/src/rules/missing_code_block_language_in_doc_comment.dart
9091
lib/src/rules/missing_whitespace_between_adjacent_strings.dart
9192
lib/src/rules/no_adjacent_strings_in_list.dart

pkg/linter/lib/src/rules/matching_super_parameters.dart

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import 'package:analyzer/dart/ast/ast.dart';
66
import 'package:analyzer/dart/ast/visitor.dart';
7-
import 'package:analyzer/dart/element/element.dart';
7+
import 'package:analyzer/dart/element/element2.dart';
88

99
import '../analyzer.dart';
1010

@@ -47,19 +47,18 @@ class _Visitor extends SimpleAstVisitor<void> {
4747
}
4848
var superInvocation =
4949
node.initializers.whereType<SuperConstructorInvocation>().firstOrNull;
50-
var superConstructor = superInvocation?.staticElement;
50+
var superConstructor = superInvocation?.element;
5151
if (superConstructor == null) {
5252
var class_ = node.parent;
5353
if (class_ is ClassDeclaration) {
54-
superConstructor =
55-
class_.declaredElement?.supertype?.element.unnamedConstructor;
54+
superConstructor = class_
55+
.declaredFragment?.element.supertype?.element3.unnamedConstructor2;
5656
}
5757
}
58-
if (superConstructor is! ConstructorElement) {
59-
return;
60-
}
58+
if (superConstructor is! ConstructorElement2) return;
59+
6160
var positionalParametersOfSuper =
62-
superConstructor.parameters.where((p) => p.isPositional).toList();
61+
superConstructor.formalParameters.where((p) => p.isPositional).toList();
6362
if (positionalParametersOfSuper.length < positionalSuperParameters.length) {
6463
// More positional parameters are passed to super constructor than it
6564
// has positional parameters, an error.
@@ -68,8 +67,9 @@ class _Visitor extends SimpleAstVisitor<void> {
6867
for (var i = 0; i < positionalSuperParameters.length; i++) {
6968
var superParameter = positionalSuperParameters[i];
7069
var superParameterName = superParameter.name.lexeme;
71-
var parameterOfSuperName = positionalParametersOfSuper[i].name;
72-
if (superParameterName != parameterOfSuperName) {
70+
var parameterOfSuperName = positionalParametersOfSuper[i].name3;
71+
if (parameterOfSuperName != null &&
72+
superParameterName != parameterOfSuperName) {
7373
rule.reportLint(superParameter,
7474
arguments: [superParameterName, parameterOfSuperName]);
7575
}

0 commit comments

Comments
 (0)