Skip to content

Commit 00dc546

Browse files
stereotype441commit-bot@chromium.org
authored andcommitted
Migration: make more use of .isNullAware throughout migration engine.
Change-Id: Iffc3f1291574450847402571c36fa7881c84de03 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/121961 Reviewed-by: Samuel Rawlins <srawlins@google.com> Reviewed-by: Konstantin Shcheglov <scheglov@google.com> Commit-Queue: Paul Berry <paulberry@google.com>
1 parent dce3d05 commit 00dc546

File tree

3 files changed

+6
-22
lines changed

3 files changed

+6
-22
lines changed

pkg/nnbd_migration/lib/src/edge_builder.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -916,8 +916,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
916916
DecoratedType visitMethodInvocation(MethodInvocation node) {
917917
DecoratedType targetType;
918918
var target = node.target;
919-
var operator = node.operator;
920-
bool isNullAware = operator != null && isNullAwareToken(operator.type);
919+
bool isNullAware = node.isNullAware;
921920
var callee = node.methodName.staticElement;
922921
bool calleeIsStatic = callee is ExecutableElement && callee.isStatic;
923922
if (node.isCascaded) {
@@ -1043,7 +1042,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
10431042
@override
10441043
DecoratedType visitPropertyAccess(PropertyAccess node) {
10451044
return _handlePropertyAccess(node, node.target, node.propertyName,
1046-
isNullAwareToken(node.operator.type), node.isCascaded);
1045+
node.isNullAware, node.isCascaded);
10471046
}
10481047

10491048
@override

pkg/nnbd_migration/lib/src/fix_builder.dart

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -218,8 +218,8 @@ abstract class FixBuilder extends GeneralizingAstVisitor<DartType>
218218
visitSubexpression(node.index, indexContext);
219219
return AssignmentTargetInfo(readType, writeType);
220220
} else if (node is PropertyAccess) {
221-
return _handleAssignmentTargetForPropertyAccess(node, node.target,
222-
node.propertyName, isNullAwareToken(node.operator.type), isCompound);
221+
return _handleAssignmentTargetForPropertyAccess(
222+
node, node.target, node.propertyName, node.isNullAware, isCompound);
223223
} else if (node is PrefixedIdentifier) {
224224
if (node.prefix.staticElement is ImportElement) {
225225
// TODO(paulberry)
@@ -505,8 +505,8 @@ abstract class FixBuilder extends GeneralizingAstVisitor<DartType>
505505

506506
@override
507507
DartType visitPropertyAccess(PropertyAccess node) {
508-
return _handlePropertyAccess(node, node.target, node.propertyName,
509-
isNullAwareToken(node.operator.type));
508+
return _handlePropertyAccess(
509+
node, node.target, node.propertyName, node.isNullAware);
510510
}
511511

512512
@override

pkg/nnbd_migration/lib/src/utilities/resolution_utils.dart

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// for details. All rights reserved. Use of this source code is governed by a
33
// BSD-style license that can be found in the LICENSE file.
44

5-
import 'package:analyzer/dart/ast/token.dart';
65
import 'package:analyzer/src/generated/resolver.dart';
76

87
/// This mixin provides utilities that are useful to visitors implementing
@@ -17,20 +16,6 @@ mixin ResolutionUtils {
1716
bool isDeclaredOnObject(String name) =>
1817
(_objectGetNames ??= _computeObjectGetNames()).contains(name);
1918

20-
/// Determines whether the given property/method access token is null-aware.
21-
bool isNullAwareToken(TokenType tokenType) {
22-
switch (tokenType) {
23-
case TokenType.PERIOD:
24-
case TokenType.PERIOD_PERIOD:
25-
return false;
26-
case TokenType.QUESTION_PERIOD:
27-
return true;
28-
default:
29-
throw new UnimplementedError(
30-
'Unexpected token passed to isNullAwareToken: $tokenType');
31-
}
32-
}
33-
3419
List<String> _computeObjectGetNames() {
3520
var result = <String>[];
3621
var objectClass = typeProvider.objectType.element;

0 commit comments

Comments
 (0)