Skip to content

Commit 25dd535

Browse files
pqCommit Queue
authored andcommitted
[element model] migrate unnecessary_null_aware_operator_on_extension_on_nullable
Bug: https://github.com/dart-lang/linter/issues/5099 Change-Id: Ic19487f8eaaea1fbd084f28390adf683aebc1350 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/387301 Commit-Queue: Phil Quitslund <[email protected]> Reviewed-by: Brian Wilkerson <[email protected]>
1 parent 12d9554 commit 25dd535

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

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

Lines changed: 9 additions & 9 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

@@ -45,9 +45,9 @@ class _Visitor extends SimpleAstVisitor<void> {
4545
_isExtensionOnNullableType(node.inSetterContext()
4646
? node
4747
.thisOrAncestorOfType<AssignmentExpression>()
48-
?.writeElement
49-
?.enclosingElement3
50-
: node.staticElement?.enclosingElement3)) {
48+
?.writeElement2
49+
?.enclosingElement2
50+
: node.element?.enclosingElement2)) {
5151
rule.reportLintForToken(node.question);
5252
}
5353
}
@@ -56,7 +56,7 @@ class _Visitor extends SimpleAstVisitor<void> {
5656
void visitMethodInvocation(MethodInvocation node) {
5757
if (node.isNullAware &&
5858
_isExtensionOnNullableType(
59-
node.methodName.staticElement?.enclosingElement3)) {
59+
node.methodName.element?.enclosingElement2)) {
6060
rule.reportLintForToken(node.operator);
6161
}
6262
}
@@ -67,14 +67,14 @@ class _Visitor extends SimpleAstVisitor<void> {
6767
var realParent = node.thisOrAncestorMatching(
6868
(p) => p != node && p is! ParenthesizedExpression);
6969
if (_isExtensionOnNullableType(realParent is AssignmentExpression
70-
? realParent.writeElement?.enclosingElement3
71-
: node.propertyName.staticElement?.enclosingElement3)) {
70+
? realParent.writeElement2?.enclosingElement2
71+
: node.propertyName.element?.enclosingElement2)) {
7272
rule.reportLintForToken(node.operator);
7373
}
7474
}
7575
}
7676

77-
bool _isExtensionOnNullableType(Element? enclosingElement) =>
78-
enclosingElement is ExtensionElement &&
77+
bool _isExtensionOnNullableType(Element2? enclosingElement) =>
78+
enclosingElement is ExtensionElement2 &&
7979
context.typeSystem.isNullable(enclosingElement.extendedType);
8080
}

0 commit comments

Comments
 (0)