Deprecate IfElement/IfStatement.condition, use 'expression'.

Change-Id: If43b4b71a21fd256ce8d1367d4b233e1cff764b9
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/296122
Commit-Queue: Konstantin Shcheglov <scheglov@google.com>
Reviewed-by: Brian Wilkerson <brianwilkerson@google.com>
Reviewed-by: Nate Bosch <nbosch@google.com>
Reviewed-by: Samuel Rawlins <srawlins@google.com>
This commit is contained in:
Konstantin Shcheglov 2023-04-19 17:17:28 +00:00 committed by Commit Queue
parent ad30add7a3
commit dc34fe9f86
44 changed files with 183 additions and 160 deletions

View file

@ -648,7 +648,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
} else if (entity == node.thenElement || entity == node.elseElement) {
_addCollectionElementKeywords();
_addExpressionKeywords(node);
} else if (entity == node.condition) {
} else if (entity == node.expression) {
_addExpressionKeywords(node);
}
return super.visitIfElement(node);
@ -675,7 +675,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor<void> {
}
} else if (entity == node.thenStatement || entity == node.elseStatement) {
_addStatementKeywords(node);
} else if (entity == node.condition) {
} else if (entity == node.expression) {
_addExpressionKeywords(node);
}
}

View file

@ -795,7 +795,7 @@ class StatementCompletionProcessor {
var stmt = _KeywordConditionBlockStructure(
node.ifKeyword,
node.leftParenthesis,
node.condition,
node.expression,
node.rightParenthesis,
node.thenStatement);
return _complete_ifOrWhileStatement(

View file

@ -195,7 +195,7 @@ abstract class CorrectionProducer extends SingleCorrectionProducer {
// if ( myFunction() ) {}
if (parent is IfStatement) {
var statement = parent;
if (statement.condition == expression) {
if (statement.expression == expression) {
return coreTypeBool;
}
}

View file

@ -68,7 +68,7 @@ class ConvertToIfCaseStatement extends CorrectionProducer {
required IfStatement ifStatement,
required bool Function() hasReferencesAfterThen,
}) async {
final isExpression = ifStatement.condition;
final isExpression = ifStatement.expression;
if (isExpression is! IsExpression) {
return;
}
@ -106,7 +106,7 @@ class ConvertToIfCaseStatement extends CorrectionProducer {
required IfStatement ifStatement,
required bool Function() hasReferencesAfterThen,
}) async {
final notEqNull = ifStatement.condition;
final notEqNull = ifStatement.expression;
if (notEqNull is! BinaryExpression) {
return;
}
@ -158,7 +158,7 @@ class ConvertToIfCaseStatement extends CorrectionProducer {
final initializerCode = utils.getNodeText(initializer);
builder.addSimpleReplacement(
range.node(ifStatement.condition),
range.node(ifStatement.expression),
'$initializerCode case $patternCode',
);
});

View file

@ -92,7 +92,7 @@ class ExtractLocalVariable extends CorrectionProducer {
return;
}
if (enclosingNode is IfStatement) {
var condition = enclosingNode.condition;
var condition = enclosingNode.expression;
if (condition is BinaryExpression &&
condition.rightOperand is NullLiteral &&
condition.operator.type == TokenType.BANG_EQ) {

View file

@ -89,14 +89,14 @@ class IntroduceLocalCastType extends CorrectionProducer {
static Expression? _getCondition(AstNode node) {
if (node is IfStatement) {
return node.condition;
return node.expression;
} else if (node is WhileStatement) {
return node.condition;
}
if (node is Expression) {
var parent = node.parent;
if (parent is IfStatement && parent.condition == node) {
if (parent is IfStatement && parent.expression == node) {
return node;
} else if (parent is WhileStatement && parent.condition == node) {
return node;

View file

@ -19,7 +19,7 @@ class InvertIfStatement extends CorrectionProducer {
if (ifStatement is! IfStatement) {
return;
}
var condition = ifStatement.condition;
var condition = ifStatement.expression;
// should have both "then" and "else"
var thenStatement = ifStatement.thenStatement;
var elseStatement = ifStatement.elseStatement;

View file

@ -38,8 +38,8 @@ class JoinIfWithInner extends CorrectionProducer {
// prepare environment
var prefix = utils.getNodePrefix(targetIfStatement);
// merge conditions
var targetCondition = targetIfStatement.condition;
var innerCondition = innerIfStatement.condition;
var targetCondition = targetIfStatement.expression;
var innerCondition = innerIfStatement.expression;
var targetConditionSource = utils.getNodeText(targetCondition);
var innerConditionSource = utils.getNodeText(innerCondition);
if (shouldWrapParenthesisBeforeAnd(targetCondition)) {

View file

@ -44,8 +44,8 @@ class JoinIfWithOuter extends CorrectionProducer {
// prepare environment
var prefix = utils.getNodePrefix(outerIfStatement);
// merge conditions
var targetCondition = targetIfStatement.condition;
var outerCondition = outerIfStatement.condition;
var targetCondition = targetIfStatement.expression;
var outerCondition = outerIfStatement.expression;
var targetConditionSource = utils.getNodeText(targetCondition);
var outerConditionSource = utils.getNodeText(outerCondition);
if (shouldWrapParenthesisBeforeAnd(targetCondition)) {

View file

@ -37,7 +37,7 @@ class ReplaceIfElseWithConditional extends CorrectionProducer {
var elseExpression = elseStatement.expression;
if (thenExpression != null && elseExpression != null) {
await builder.addDartFileEdit(file, (builder) {
var conditionSrc = utils.getNodeText(ifStatement.condition);
var conditionSrc = utils.getNodeText(ifStatement.expression);
var thenSrc = utils.getNodeText(thenExpression);
var elseSrc = utils.getNodeText(elseExpression);
builder.addSimpleReplacement(range.node(ifStatement),
@ -58,7 +58,7 @@ class ReplaceIfElseWithConditional extends CorrectionProducer {
if (thenAssignment.operator.type == TokenType.EQ &&
elseAssignment.operator.type == TokenType.EQ &&
thenTarget == elseTarget) {
var conditionSrc = utils.getNodeText(ifStatement.condition);
var conditionSrc = utils.getNodeText(ifStatement.expression);
var thenSrc = utils.getNodeText(thenAssignment.rightHandSide);
var elseSrc = utils.getNodeText(elseAssignment.rightHandSide);
builder.addSimpleReplacement(range.node(ifStatement),

View file

@ -46,7 +46,7 @@ class SplitAndCondition extends CorrectionProducer {
TokenType.AMPERSAND_AMPERSAND) {
condition = condition.parent as BinaryExpression;
}
if (ifStatement.condition != condition) {
if (ifStatement.expression != condition) {
return;
}
// prepare environment

View file

@ -35,7 +35,7 @@ void f(bool? b4, bool? b5) {
}
''');
var ifStatement = findNode.ifStatement('if (');
var condition = ifStatement.condition;
var condition = ifStatement.expression;
var result = CorrectionUtils(testAnalysisResult).invertCondition(condition);
expect(result, expected);
// For compactness we put multiple cases into one test method.

View file

@ -755,7 +755,7 @@ class CodeShapeDataCollector extends RecursiveAstVisitor<void> {
@override
void visitIfElement(IfElement node) {
_visitChildren(node, {
'condition': node.condition,
'condition': node.expression,
'thenElement': node.thenElement,
'elseElement': node.elseElement,
});
@ -765,7 +765,7 @@ class CodeShapeDataCollector extends RecursiveAstVisitor<void> {
@override
void visitIfStatement(IfStatement node) {
_visitChildren(node, {
'condition': node.condition,
'condition': node.expression,
'thenStatement': node.thenStatement,
'elseStatement': node.elseStatement,
});

View file

@ -825,7 +825,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
@override
void visitIfElement(IfElement node) {
_recordDataForNode('IfElement (condition)', node.condition,
_recordDataForNode('IfElement (condition)', node.expression,
allowedKeywords: expressionKeywords);
_recordDataForNode('IfElement (then)', node.thenElement);
_recordDataForNode('IfElement (else)', node.elseElement);
@ -834,7 +834,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
@override
void visitIfStatement(IfStatement node) {
_recordDataForNode('IfStatement (condition)', node.condition,
_recordDataForNode('IfStatement (condition)', node.expression,
allowedKeywords: expressionKeywords);
_recordDataForNode('IfStatement (then)', node.thenStatement,
allowedKeywords: statementKeywords);

View file

@ -798,7 +798,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
@override
void visitIfElement(IfElement node) {
_recordDataForNode('IfElement_condition', node.condition,
_recordDataForNode('IfElement_condition', node.expression,
allowedKeywords: expressionKeywords);
_recordDataForNode('IfElement_thenElement', node.thenElement);
_recordDataForNode('IfElement_elseElement', node.elseElement);
@ -807,7 +807,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor<void> {
@override
void visitIfStatement(IfStatement node) {
_recordDataForNode('IfStatement_condition', node.condition,
_recordDataForNode('IfStatement_condition', node.expression,
allowedKeywords: expressionKeywords);
_recordDataForNode('IfStatement_thenStatement', node.thenStatement,
allowedKeywords: statementKeywords);

View file

@ -1,5 +1,6 @@
## 5.11.0-dev
* Removed `@experimental` from AST nodes and elements for records and patterns.
* Deprecated `IfStatement.condition`, use `expression` instead.
## 5.10.0
* Added `DartType.isDartCoreType`.

View file

@ -3011,12 +3011,12 @@ abstract class Identifier implements Expression, CommentReferableExpression {
///
/// Clients may not extend, implement or mix-in this class.
abstract class IfElement implements CollectionElement {
/// Return the `case` clause used to match a pattern against the [condition].
/// Return the `case` clause used to match a pattern against the [expression].
CaseClause? get caseClause;
/// Return the condition used to determine which of the statements is executed
/// next.
// TODO(brianwilkerson) Deprecate this when the patterns feature is released.
@Deprecated('Use expression instead')
Expression get condition;
/// Return the statement that is executed if the condition evaluates to
@ -3054,12 +3054,12 @@ abstract class IfElement implements CollectionElement {
///
/// Clients may not extend, implement or mix-in this class.
abstract class IfStatement implements Statement {
/// Return the `case` clause used to match a pattern against the [condition].
/// Return the `case` clause used to match a pattern against the [expression].
CaseClause? get caseClause;
/// Return the condition used to determine which of the statements is executed
/// next.
// TODO(brianwilkerson) Deprecate this when the patterns feature is released.
@Deprecated('Use expression instead')
Expression get condition;
/// Return the token representing the 'else' keyword, or `null` if there is no

View file

@ -144,7 +144,7 @@ transforms:
newName: 'isAccessibleIn'
# buildSdkSummary()
- title: "Replace with get buildSdkSummary()"
- title: "Replace with buildSdkSummary()"
date: 2022-10-24
element:
function: 'buildSdkSummary2'
@ -152,3 +152,23 @@ transforms:
changes:
- kind: 'rename'
newName: 'buildSdkSummary'
# condition -> expression
- title: "Replace with get expression"
date: 2023-04-18
element:
method: 'condition'
uris: [ 'package:analyzer/dart/ast/ast.dart' ]
inClass: 'IfStatement'
changes:
- kind: rename
newName: 'expression'
- title: "Replace with get expression"
date: 2023-04-18
element:
method: 'condition'
uris: [ 'package:analyzer/dart/ast/ast.dart' ]
inClass: 'IfElement'
changes:
- kind: rename
newName: 'expression'

View file

@ -6792,7 +6792,7 @@ class IfElementImpl extends CollectionElementImpl
@override
final Token leftParenthesis;
ExpressionImpl _condition;
ExpressionImpl _expression;
@override
final CaseClauseImpl? caseClause;
@ -6814,16 +6814,16 @@ class IfElementImpl extends CollectionElementImpl
IfElementImpl({
required this.ifKeyword,
required this.leftParenthesis,
required ExpressionImpl condition,
required ExpressionImpl expression,
required this.caseClause,
required this.rightParenthesis,
required CollectionElementImpl thenElement,
required this.elseKeyword,
required CollectionElementImpl? elseElement,
}) : _condition = condition,
}) : _expression = expression,
_thenElement = thenElement,
_elseElement = elseElement {
_becomeParentOf(_condition);
_becomeParentOf(_expression);
_becomeParentOf(caseClause);
_becomeParentOf(_thenElement);
_becomeParentOf(_elseElement);
@ -6832,11 +6832,12 @@ class IfElementImpl extends CollectionElementImpl
@override
Token get beginToken => ifKeyword;
@Deprecated('Use expression instead')
@override
ExpressionImpl get condition => _condition;
ExpressionImpl get condition => _expression;
set condition(ExpressionImpl condition) {
_condition = _becomeParentOf(condition);
_expression = _becomeParentOf(condition);
}
@override
@ -6850,7 +6851,7 @@ class IfElementImpl extends CollectionElementImpl
Token get endToken => _elseElement?.endToken ?? _thenElement.endToken;
@override
ExpressionImpl get expression => _condition;
ExpressionImpl get expression => _expression;
@override
CollectionElementImpl? get ifFalse => elseElement;
@ -6869,7 +6870,7 @@ class IfElementImpl extends CollectionElementImpl
ChildEntities get _childEntities => ChildEntities()
..addToken('ifKeyword', ifKeyword)
..addToken('leftParenthesis', leftParenthesis)
..addNode('condition', condition)
..addNode('expression', expression)
..addNode('caseClause', caseClause)
..addToken('rightParenthesis', rightParenthesis)
..addNode('thenElement', thenElement)
@ -6888,7 +6889,7 @@ class IfElementImpl extends CollectionElementImpl
@override
void visitChildren(AstVisitor visitor) {
condition.accept(visitor);
expression.accept(visitor);
caseClause?.accept(visitor);
_thenElement.accept(visitor);
_elseElement?.accept(visitor);
@ -6926,7 +6927,7 @@ class IfStatementImpl extends StatementImpl
final Token leftParenthesis;
/// The condition used to determine which of the branches is executed next.
ExpressionImpl _condition;
ExpressionImpl _expression;
@override
final CaseClauseImpl? caseClause;
@ -6949,16 +6950,16 @@ class IfStatementImpl extends StatementImpl
IfStatementImpl({
required this.ifKeyword,
required this.leftParenthesis,
required ExpressionImpl condition,
required ExpressionImpl expression,
required this.caseClause,
required this.rightParenthesis,
required StatementImpl thenStatement,
required this.elseKeyword,
required StatementImpl? elseStatement,
}) : _condition = condition,
}) : _expression = expression,
_thenStatement = thenStatement,
_elseStatement = elseStatement {
_becomeParentOf(_condition);
_becomeParentOf(_expression);
_becomeParentOf(caseClause);
_becomeParentOf(_thenStatement);
_becomeParentOf(_elseStatement);
@ -6967,11 +6968,12 @@ class IfStatementImpl extends StatementImpl
@override
Token get beginToken => ifKeyword;
@Deprecated('Use expression instead')
@override
ExpressionImpl get condition => _condition;
ExpressionImpl get condition => _expression;
set condition(ExpressionImpl condition) {
_condition = _becomeParentOf(condition);
_expression = _becomeParentOf(condition);
}
@override
@ -6990,7 +6992,7 @@ class IfStatementImpl extends StatementImpl
}
@override
ExpressionImpl get expression => _condition;
ExpressionImpl get expression => _expression;
@override
StatementImpl? get ifFalse => elseStatement;
@ -7009,7 +7011,7 @@ class IfStatementImpl extends StatementImpl
ChildEntities get _childEntities => ChildEntities()
..addToken('ifKeyword', ifKeyword)
..addToken('leftParenthesis', leftParenthesis)
..addNode('condition', condition)
..addNode('expression', expression)
..addNode('caseClause', caseClause)
..addToken('rightParenthesis', rightParenthesis)
..addNode('thenStatement', thenStatement)
@ -7021,7 +7023,7 @@ class IfStatementImpl extends StatementImpl
@override
void visitChildren(AstVisitor visitor) {
_condition.accept(visitor);
_expression.accept(visitor);
caseClause?.accept(visitor);
_thenStatement.accept(visitor);
_elseStatement?.accept(visitor);

View file

@ -674,7 +674,7 @@ class ToSourceVisitor implements AstVisitor<void> {
@override
void visitIfElement(IfElement node) {
sink.write('if (');
_visitNode(node.condition);
_visitNode(node.expression);
_visitNode(node.caseClause, prefix: ' ');
sink.write(') ');
_visitNode(node.thenElement);
@ -684,7 +684,7 @@ class ToSourceVisitor implements AstVisitor<void> {
@override
void visitIfStatement(IfStatement node) {
sink.write('if (');
_visitNode(node.condition);
_visitNode(node.expression);
_visitNode(node.caseClause, prefix: ' ');
sink.write(') ');
_visitNode(node.thenStatement);

View file

@ -781,7 +781,7 @@ class AstComparator implements AstVisitor<bool> {
IfElement other = _other as IfElement;
return isEqualTokens(node.ifKeyword, other.ifKeyword) &&
isEqualTokens(node.leftParenthesis, other.leftParenthesis) &&
isEqualNodes(node.condition, other.condition) &&
isEqualNodes(node.expression, other.expression) &&
isEqualTokens(node.rightParenthesis, other.rightParenthesis) &&
isEqualNodes(node.thenElement, other.thenElement) &&
isEqualTokens(node.elseKeyword, other.elseKeyword) &&
@ -793,7 +793,7 @@ class AstComparator implements AstVisitor<bool> {
IfStatement other = _other as IfStatement;
return isEqualTokens(node.ifKeyword, other.ifKeyword) &&
isEqualTokens(node.leftParenthesis, other.leftParenthesis) &&
isEqualNodes(node.condition, other.condition) &&
isEqualNodes(node.expression, other.expression) &&
isEqualTokens(node.rightParenthesis, other.rightParenthesis) &&
isEqualNodes(node.thenStatement, other.thenStatement) &&
isEqualTokens(node.elseKeyword, other.elseKeyword) &&
@ -2720,7 +2720,7 @@ class NodeReplacer extends ThrowingAstVisitor<bool> {
@override
bool visitIfElement(IfElement node) {
if (identical(node.condition, _oldNode)) {
if (identical(node.expression, _oldNode)) {
(node as IfElementImpl).condition = _newNode as ExpressionImpl;
return true;
} else if (identical(node.thenElement, _oldNode)) {
@ -2735,7 +2735,7 @@ class NodeReplacer extends ThrowingAstVisitor<bool> {
@override
bool visitIfStatement(covariant IfStatementImpl node) {
if (identical(node.condition, _oldNode)) {
if (identical(node.expression, _oldNode)) {
node.condition = _newNode as ExpressionImpl;
return true;
} else if (identical(node.thenStatement, _oldNode)) {

View file

@ -1004,7 +1004,7 @@ class _ConstLiteralVerifier {
verifier._errorReporter.reportErrorForNode(errorCode, element);
return false;
} else if (element is IfElement) {
var conditionValue = verifier._validate(element.condition, errorCode);
var conditionValue = verifier._validate(element.expression, errorCode);
var conditionBool = conditionValue?.toBoolValue();
// The errors have already been reported.

View file

@ -1185,7 +1185,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (element is ForElement) {
_error(element, null);
} else if (element is IfElement) {
var conditionValue = _evaluateCondition(element.condition);
var conditionValue = _evaluateCondition(element.expression);
if (conditionValue == null) {
return true;
} else if (conditionValue) {
@ -1222,7 +1222,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (element is ForElement) {
_error(element, null);
} else if (element is IfElement) {
var conditionValue = _evaluateCondition(element.condition);
var conditionValue = _evaluateCondition(element.expression);
if (conditionValue == null) {
return true;
} else if (conditionValue) {
@ -1259,7 +1259,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
if (element is ForElement) {
_error(element, null);
} else if (element is IfElement) {
var conditionValue = _evaluateCondition(element.condition);
var conditionValue = _evaluateCondition(element.expression);
if (conditionValue == null) {
return true;
} else if (conditionValue) {
@ -1512,7 +1512,7 @@ class ConstantVisitor extends UnifyingAstVisitor<DartObjectImpl> {
} else if (current is DefaultFormalParameter) {
return CompileTimeErrorCode
.NON_CONSTANT_DEFAULT_VALUE_FROM_DEFERRED_LIBRARY;
} else if (current is IfElement && current.condition == node) {
} else if (current is IfElement && current.expression == node) {
return CompileTimeErrorCode
.IF_ELEMENT_CONDITION_FROM_DEFERRED_LIBRARY;
} else if (current is ListLiteral) {

View file

@ -183,7 +183,7 @@ class _Collector {
}
if (node is IfElement) {
collect(node.condition);
collect(node.expression);
collect(node.thenElement);
if (node.elseElement != null) {
collect(node.elseElement!);

View file

@ -322,7 +322,7 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
@override
bool visitIfElement(IfElement node) {
var conditionExpression = node.condition;
var conditionExpression = node.expression;
var thenElement = node.thenElement;
var elseElement = node.elseElement;
if (_nodeExits(conditionExpression)) {
@ -346,7 +346,7 @@ class ExitDetector extends GeneralizingAstVisitor<bool> {
@override
bool visitIfStatement(IfStatement node) {
var conditionExpression = node.condition;
var conditionExpression = node.expression;
var thenStatement = node.thenStatement;
var elseStatement = node.elseStatement;
if (_nodeExits(conditionExpression)) {

View file

@ -1286,7 +1286,7 @@ class BestPracticesVerifier extends RecursiveAstVisitor<void> {
}
// NULL_AWARE_IN_CONDITION
if (parent is IfStatement && parent.condition == childOfParent ||
if (parent is IfStatement && parent.expression == childOfParent ||
parent is ForPartsWithDeclarations &&
parent.condition == childOfParent ||
parent is DoStatement && parent.condition == childOfParent ||

View file

@ -234,7 +234,7 @@ class LegacyDeadCodeVerifier extends RecursiveAstVisitor<void> {
@override
void visitIfElement(IfElement node) {
Expression conditionExpression = node.condition;
Expression conditionExpression = node.expression;
conditionExpression.accept(this);
if (!_isDebugConstant(conditionExpression)) {
var result = _getConstantBooleanValue(conditionExpression);
@ -262,7 +262,7 @@ class LegacyDeadCodeVerifier extends RecursiveAstVisitor<void> {
@override
void visitIfStatement(IfStatement node) {
Expression conditionExpression = node.condition;
Expression conditionExpression = node.expression;
conditionExpression.accept(this);
if (!_isDebugConstant(conditionExpression)) {
var result = _getConstantBooleanValue(conditionExpression);

View file

@ -2248,7 +2248,7 @@ class AstBuilder extends StackListener {
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
condition: condition.expression,
expression: condition.expression,
caseClause: condition.caseClause,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
@ -2269,7 +2269,7 @@ class AstBuilder extends StackListener {
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
condition: condition.expression,
expression: condition.expression,
caseClause: condition.caseClause,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
@ -2291,7 +2291,7 @@ class AstBuilder extends StackListener {
IfStatementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
condition: condition.expression,
expression: condition.expression,
caseClause: condition.caseClause,
rightParenthesis: condition.rightParenthesis,
thenStatement: thenPart,

View file

@ -654,11 +654,11 @@ class AstBinaryReader {
}
IfElement _readIfElement() {
var condition = readNode() as ExpressionImpl;
var expression = readNode() as ExpressionImpl;
var thenElement = readNode() as CollectionElementImpl;
var elseElement = _readOptionalNode() as CollectionElementImpl?;
return IfElementImpl(
condition: condition,
expression: expression,
caseClause: null,
elseElement: elseElement,
elseKeyword: elseElement != null ? Tokens.else_() : null,

View file

@ -341,7 +341,7 @@ class AstBinaryWriter extends ThrowingAstVisitor<void> {
@override
void visitIfElement(IfElement node) {
_writeByte(Tag.IfElement);
_writeNode(node.condition);
_writeNode(node.expression);
_writeNode(node.thenElement);
_writeOptionalNode(node.elseElement);
}

View file

@ -187,12 +187,12 @@ class ClassMemberParserTest extends FastaParserTestCase
expect(body, isBlockFunctionBody);
Statement statement = (body as BlockFunctionBody).block.statements[0];
expect(statement, isIfStatement);
Expression expression = (statement as IfStatement).condition;
Expression expression = (statement as IfStatement).expression;
expect(expression, isAwaitExpression);
expect(statement.elseStatement, isNotNull);
Statement elseStatement = statement.elseStatement!;
expect(elseStatement, isIfStatement);
expression = (elseStatement as IfStatement).condition;
expression = (elseStatement as IfStatement).expression;
expect(expression, isPrefixExpression);
expect((expression as PrefixExpression).operator.lexeme, '!');
expression = expression.operand;

View file

@ -76,7 +76,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(iterable.name, 'list');
var body = second.body as IfElement;
var condition = body.condition as SimpleIdentifier;
var condition = body.expression as SimpleIdentifier;
expect(condition.name, 'c');
var thenElement = body.thenElement as IntegerLiteral;
expect(thenElement.value, 2);
@ -113,7 +113,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = list.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as IntegerLiteral;
expect(thenElement.value, 2);
@ -127,7 +127,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = list.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as IntegerLiteral;
expect(thenElement.value, 2);
@ -143,7 +143,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = list.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as IntegerLiteral;
expect(thenElement.value, 2);
@ -164,7 +164,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = list.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as SpreadElement;
expect(thenElement.spreadOperator.lexeme, '...');
@ -180,7 +180,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = list.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as ForElement;
@ -199,7 +199,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = list.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as SpreadElement;
expect(thenElement.spreadOperator.lexeme, '...');
@ -272,7 +272,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(iterable.name, 'list');
var body = second.body as IfElement;
var condition = body.condition as SimpleIdentifier;
var condition = body.expression as SimpleIdentifier;
expect(condition.name, 'c');
var thenElement = body.thenElement as MapLiteralEntry;
var thenValue = thenElement.value as IntegerLiteral;
@ -312,7 +312,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(firstValue.value, 1);
var second = map.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as MapLiteralEntry;
var thenElementValue = thenElement.value as IntegerLiteral;
@ -329,7 +329,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(firstValue.value, 1);
var second = map.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as MapLiteralEntry;
var thenElementValue = thenElement.value as IntegerLiteral;
@ -349,7 +349,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(firstValue.value, 1);
var second = map.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as MapLiteralEntry;
var thenElementValue = thenElement.value as IntegerLiteral;
@ -373,7 +373,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(firstValue.value, 7);
var second = map.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as SpreadElement;
expect(thenElement.spreadOperator.lexeme, '...');
@ -395,7 +395,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(firstValue.value, 1);
var second = map.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as ForElement;
@ -417,7 +417,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(firstValue.value, 1);
var second = map.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as SpreadElement;
expect(thenElement.spreadOperator.lexeme, '...');
@ -508,7 +508,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = setLiteral.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as IntegerLiteral;
expect(thenElement.value, 2);
@ -523,7 +523,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = setLiteral.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as IntegerLiteral;
expect(thenElement.value, 2);
@ -540,7 +540,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = setLiteral.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as SpreadElement;
expect(thenElement.spreadOperator.lexeme, '...');
@ -560,7 +560,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase {
expect(first.value, 1);
var second = setLiteral.elements[1] as IfElement;
var condition = second.condition as BooleanLiteral;
var condition = second.expression as BooleanLiteral;
expect(condition.value, isTrue);
var thenElement = second.thenElement as SpreadElement;
expect(thenElement.spreadOperator.lexeme, '...');

View file

@ -61,7 +61,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -90,7 +90,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -122,7 +122,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -152,7 +152,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -215,7 +215,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -240,7 +240,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -268,7 +268,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -319,7 +319,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -353,7 +353,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -390,7 +390,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -459,7 +459,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -489,7 +489,7 @@ void f(x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -522,7 +522,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -3243,7 +3243,7 @@ f(x, y) => [if (x case _ when y + () => 0) 0];
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@ -3281,7 +3281,7 @@ f(x, y) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case

View file

@ -1077,7 +1077,7 @@ class C {
MethodDeclaration method = declaration.members[0] as MethodDeclaration;
BlockFunctionBody body = method.body as BlockFunctionBody;
IfStatement ifStatement = body.block.statements[1] as IfStatement;
IsExpression expression = ifStatement.condition as IsExpression;
IsExpression expression = ifStatement.expression as IsExpression;
expect(expression.expression, isNotNull);
expect(expression.isOperator, isNotNull);
expect(expression.notOperator, isNotNull);

View file

@ -875,7 +875,7 @@ main() {
assertNoErrors();
expect(statement.ifKeyword, isNotNull);
expect(statement.leftParenthesis, isNotNull);
expect(statement.condition, isNotNull);
expect(statement.expression, isNotNull);
expect(statement.rightParenthesis, isNotNull);
expect(statement.thenStatement, isNotNull);
expect(statement.elseKeyword, isNotNull);
@ -887,7 +887,7 @@ main() {
assertNoErrors();
expect(statement.ifKeyword, isNotNull);
expect(statement.leftParenthesis, isNotNull);
expect(statement.condition, isNotNull);
expect(statement.expression, isNotNull);
expect(statement.rightParenthesis, isNotNull);
expect(statement.thenStatement, isNotNull);
expect(statement.elseKeyword, isNotNull);
@ -899,7 +899,7 @@ main() {
assertNoErrors();
expect(statement.ifKeyword, isNotNull);
expect(statement.leftParenthesis, isNotNull);
expect(statement.condition, isNotNull);
expect(statement.expression, isNotNull);
expect(statement.rightParenthesis, isNotNull);
expect(statement.thenStatement, isNotNull);
expect(statement.elseKeyword, isNotNull);
@ -911,7 +911,7 @@ main() {
assertNoErrors();
expect(statement.ifKeyword, isNotNull);
expect(statement.leftParenthesis, isNotNull);
expect(statement.condition, isNotNull);
expect(statement.expression, isNotNull);
expect(statement.rightParenthesis, isNotNull);
expect(statement.thenStatement, isNotNull);
expect(statement.elseKeyword, isNull);
@ -923,7 +923,7 @@ main() {
assertNoErrors();
expect(statement.ifKeyword, isNotNull);
expect(statement.leftParenthesis, isNotNull);
expect(statement.condition, isNotNull);
expect(statement.expression, isNotNull);
expect(statement.rightParenthesis, isNotNull);
expect(statement.thenStatement, isNotNull);
expect(statement.elseKeyword, isNull);

View file

@ -1114,7 +1114,7 @@ void f() {
destination: findNode.ifStatement('true'),
source: findNode.ifStatement('false'),
childAccessors: [
(node) => node.condition,
(node) => node.expression,
(node) => node.thenStatement,
(node) => node.elseStatement!,
],

View file

@ -28,7 +28,7 @@ void f(Object x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@ -62,7 +62,7 @@ final y = [ if (x case var a) a ];
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@getter::x
staticType: int
@ -112,7 +112,7 @@ void f(Object x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@ -191,7 +191,7 @@ void f(Object x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@ -254,7 +254,7 @@ class A {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SuperExpression
expression: SuperExpression
superKeyword: super
staticType: A
rightParenthesis: )
@ -284,7 +284,7 @@ class A {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@ -326,7 +326,7 @@ void f(bool Function() a) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: FunctionExpressionInvocation
expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@ -356,7 +356,7 @@ void f(int Function() a) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: FunctionExpressionInvocation
expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@ -394,7 +394,7 @@ void f(Object x, bool Function() a) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@ -438,7 +438,7 @@ void f(Object x) {
IfElement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object

View file

@ -28,7 +28,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
@ -61,7 +61,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -144,7 +144,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -228,7 +228,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -313,7 +313,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -397,7 +397,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -476,7 +476,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -559,7 +559,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -650,7 +650,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -736,7 +736,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -815,7 +815,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -912,7 +912,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -1006,7 +1006,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -1082,7 +1082,7 @@ void f(Object? x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@ -1157,7 +1157,7 @@ class A {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SuperExpression
expression: SuperExpression
superKeyword: super
staticType: A
rightParenthesis: )
@ -1183,7 +1183,7 @@ class A {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
@ -1225,7 +1225,7 @@ void f(bool Function() a) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: FunctionExpressionInvocation
expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@ -1255,7 +1255,7 @@ void f(int Function() a) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: FunctionExpressionInvocation
expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@ -1293,7 +1293,7 @@ void f(x, bool Function() a) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
@ -1337,7 +1337,7 @@ void f(x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic

View file

@ -31,7 +31,7 @@ void f(int x) {
IfStatement
ifKeyword: if
leftParenthesis: (
condition: SimpleIdentifier
expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: int

View file

@ -15207,7 +15207,7 @@ library
IfElement
ifKeyword: if @29
leftParenthesis: ( @32
condition: BooleanLiteral
expression: BooleanLiteral
literal: true @33
staticType: bool
rightParenthesis: ) @37
@ -15251,7 +15251,7 @@ library
IfElement
ifKeyword: if @29
leftParenthesis: ( @32
condition: BooleanLiteral
expression: BooleanLiteral
literal: true @33
staticType: bool
rightParenthesis: ) @37
@ -15443,7 +15443,7 @@ library
IfElement
ifKeyword: if @34
leftParenthesis: ( @37
condition: BooleanLiteral
expression: BooleanLiteral
literal: true @38
staticType: bool
rightParenthesis: ) @42
@ -17259,7 +17259,7 @@ library
IfElement
ifKeyword: if @29
leftParenthesis: ( @32
condition: BooleanLiteral
expression: BooleanLiteral
literal: true @33
staticType: bool
rightParenthesis: ) @37

View file

@ -927,7 +927,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor<void> {
@override
void visitIfElement(IfElement node) {
if (identical(entity, node.condition)) {
if (identical(entity, node.expression)) {
optype.completionLocation = 'IfElement_condition';
optype.includeReturnValueSuggestions = true;
optype.includeTypeNameSuggestions = true;
@ -949,7 +949,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor<void> {
if (_isEntityPrevTokenSynthetic()) {
// Actual: if (var v i^)
// Parsed: if (v) i^;
} else if (identical(entity, node.condition)) {
} else if (identical(entity, node.expression)) {
optype.completionLocation = 'IfStatement_condition';
optype.includeReturnValueSuggestions = true;
optype.includeTypeNameSuggestions = true;

View file

@ -1117,11 +1117,11 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
@override
DecoratedType? visitIfElement(IfElement node) {
_flowAnalysis!.ifStatement_conditionBegin();
_checkExpressionNotNull(node.condition);
_flowAnalysis!.ifStatement_thenBegin(node.condition, node);
_checkExpressionNotNull(node.expression);
_flowAnalysis!.ifStatement_thenBegin(node.expression, node);
NullabilityNode? trueGuard;
NullabilityNode? falseGuard;
if (identical(_conditionInfo?.condition, node.condition)) {
if (identical(_conditionInfo?.condition, node.expression)) {
trueGuard = _conditionInfo!.trueGuard;
falseGuard = _conditionInfo!.falseGuard;
_variables.recordConditionalDiscard(source, node,
@ -1159,10 +1159,10 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
@override
DecoratedType? visitIfStatement(IfStatement node) {
_flowAnalysis!.ifStatement_conditionBegin();
_checkExpressionNotNull(node.condition);
_checkExpressionNotNull(node.expression);
NullabilityNode? trueGuard;
NullabilityNode? falseGuard;
if (identical(_conditionInfo?.condition, node.condition)) {
if (identical(_conditionInfo?.condition, node.expression)) {
trueGuard = _conditionInfo!.trueGuard;
falseGuard = _conditionInfo!.falseGuard;
_variables.recordConditionalDiscard(source, node,
@ -1172,7 +1172,7 @@ class EdgeBuilder extends GeneralizingAstVisitor<DecoratedType>
_guards.add(trueGuard);
}
try {
_flowAnalysis!.ifStatement_thenBegin(node.condition, node);
_flowAnalysis!.ifStatement_thenBegin(node.expression, node);
// We branched, so create a new scope for post-dominators.
_postDominatedLocals.doScoped(
action: () => _dispatch(node.thenStatement));

View file

@ -889,8 +889,8 @@ class NodeChangeForIfElement extends NodeChange<IfElement>
@override
EditPlan _apply(IfElement node, FixAggregator aggregator) {
return _applyConditional(node, aggregator, node.condition, node.thenElement,
node.elseElement) ??
return _applyConditional(node, aggregator, node.expression,
node.thenElement, node.elseElement) ??
aggregator.innerPlanForNode(node);
}
}
@ -903,7 +903,7 @@ class NodeChangeForIfStatement extends NodeChange<IfStatement>
@override
EditPlan _apply(IfStatement node, FixAggregator aggregator) {
return _applyConditional(node, aggregator, node.condition,
return _applyConditional(node, aggregator, node.expression,
node.thenStatement, node.elseStatement) ??
aggregator.innerPlanForNode(node);
}

View file

@ -272,7 +272,7 @@ class NullVisitor extends ScrapeVisitor {
}
String? context;
if (parent is IfStatement && node == parent.condition) {
if (parent is IfStatement && node == parent.expression) {
context = 'if';
} else if (parent is BinaryExpression &&
parent.operator.type == TokenType.AMPERSAND_AMPERSAND) {