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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -1,5 +1,6 @@
## 5.11.0-dev ## 5.11.0-dev
* Removed `@experimental` from AST nodes and elements for records and patterns. * Removed `@experimental` from AST nodes and elements for records and patterns.
* Deprecated `IfStatement.condition`, use `expression` instead.
## 5.10.0 ## 5.10.0
* Added `DartType.isDartCoreType`. * 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. /// Clients may not extend, implement or mix-in this class.
abstract class IfElement implements CollectionElement { 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; CaseClause? get caseClause;
/// Return the condition used to determine which of the statements is executed /// Return the condition used to determine which of the statements is executed
/// next. /// next.
// TODO(brianwilkerson) Deprecate this when the patterns feature is released. @Deprecated('Use expression instead')
Expression get condition; Expression get condition;
/// Return the statement that is executed if the condition evaluates to /// 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. /// Clients may not extend, implement or mix-in this class.
abstract class IfStatement implements Statement { 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; CaseClause? get caseClause;
/// Return the condition used to determine which of the statements is executed /// Return the condition used to determine which of the statements is executed
/// next. /// next.
// TODO(brianwilkerson) Deprecate this when the patterns feature is released. @Deprecated('Use expression instead')
Expression get condition; Expression get condition;
/// Return the token representing the 'else' keyword, or `null` if there is no /// Return the token representing the 'else' keyword, or `null` if there is no

View file

@ -144,7 +144,7 @@ transforms:
newName: 'isAccessibleIn' newName: 'isAccessibleIn'
# buildSdkSummary() # buildSdkSummary()
- title: "Replace with get buildSdkSummary()" - title: "Replace with buildSdkSummary()"
date: 2022-10-24 date: 2022-10-24
element: element:
function: 'buildSdkSummary2' function: 'buildSdkSummary2'
@ -152,3 +152,23 @@ transforms:
changes: changes:
- kind: 'rename' - kind: 'rename'
newName: 'buildSdkSummary' 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 @override
final Token leftParenthesis; final Token leftParenthesis;
ExpressionImpl _condition; ExpressionImpl _expression;
@override @override
final CaseClauseImpl? caseClause; final CaseClauseImpl? caseClause;
@ -6814,16 +6814,16 @@ class IfElementImpl extends CollectionElementImpl
IfElementImpl({ IfElementImpl({
required this.ifKeyword, required this.ifKeyword,
required this.leftParenthesis, required this.leftParenthesis,
required ExpressionImpl condition, required ExpressionImpl expression,
required this.caseClause, required this.caseClause,
required this.rightParenthesis, required this.rightParenthesis,
required CollectionElementImpl thenElement, required CollectionElementImpl thenElement,
required this.elseKeyword, required this.elseKeyword,
required CollectionElementImpl? elseElement, required CollectionElementImpl? elseElement,
}) : _condition = condition, }) : _expression = expression,
_thenElement = thenElement, _thenElement = thenElement,
_elseElement = elseElement { _elseElement = elseElement {
_becomeParentOf(_condition); _becomeParentOf(_expression);
_becomeParentOf(caseClause); _becomeParentOf(caseClause);
_becomeParentOf(_thenElement); _becomeParentOf(_thenElement);
_becomeParentOf(_elseElement); _becomeParentOf(_elseElement);
@ -6832,11 +6832,12 @@ class IfElementImpl extends CollectionElementImpl
@override @override
Token get beginToken => ifKeyword; Token get beginToken => ifKeyword;
@Deprecated('Use expression instead')
@override @override
ExpressionImpl get condition => _condition; ExpressionImpl get condition => _expression;
set condition(ExpressionImpl condition) { set condition(ExpressionImpl condition) {
_condition = _becomeParentOf(condition); _expression = _becomeParentOf(condition);
} }
@override @override
@ -6850,7 +6851,7 @@ class IfElementImpl extends CollectionElementImpl
Token get endToken => _elseElement?.endToken ?? _thenElement.endToken; Token get endToken => _elseElement?.endToken ?? _thenElement.endToken;
@override @override
ExpressionImpl get expression => _condition; ExpressionImpl get expression => _expression;
@override @override
CollectionElementImpl? get ifFalse => elseElement; CollectionElementImpl? get ifFalse => elseElement;
@ -6869,7 +6870,7 @@ class IfElementImpl extends CollectionElementImpl
ChildEntities get _childEntities => ChildEntities() ChildEntities get _childEntities => ChildEntities()
..addToken('ifKeyword', ifKeyword) ..addToken('ifKeyword', ifKeyword)
..addToken('leftParenthesis', leftParenthesis) ..addToken('leftParenthesis', leftParenthesis)
..addNode('condition', condition) ..addNode('expression', expression)
..addNode('caseClause', caseClause) ..addNode('caseClause', caseClause)
..addToken('rightParenthesis', rightParenthesis) ..addToken('rightParenthesis', rightParenthesis)
..addNode('thenElement', thenElement) ..addNode('thenElement', thenElement)
@ -6888,7 +6889,7 @@ class IfElementImpl extends CollectionElementImpl
@override @override
void visitChildren(AstVisitor visitor) { void visitChildren(AstVisitor visitor) {
condition.accept(visitor); expression.accept(visitor);
caseClause?.accept(visitor); caseClause?.accept(visitor);
_thenElement.accept(visitor); _thenElement.accept(visitor);
_elseElement?.accept(visitor); _elseElement?.accept(visitor);
@ -6926,7 +6927,7 @@ class IfStatementImpl extends StatementImpl
final Token leftParenthesis; final Token leftParenthesis;
/// The condition used to determine which of the branches is executed next. /// The condition used to determine which of the branches is executed next.
ExpressionImpl _condition; ExpressionImpl _expression;
@override @override
final CaseClauseImpl? caseClause; final CaseClauseImpl? caseClause;
@ -6949,16 +6950,16 @@ class IfStatementImpl extends StatementImpl
IfStatementImpl({ IfStatementImpl({
required this.ifKeyword, required this.ifKeyword,
required this.leftParenthesis, required this.leftParenthesis,
required ExpressionImpl condition, required ExpressionImpl expression,
required this.caseClause, required this.caseClause,
required this.rightParenthesis, required this.rightParenthesis,
required StatementImpl thenStatement, required StatementImpl thenStatement,
required this.elseKeyword, required this.elseKeyword,
required StatementImpl? elseStatement, required StatementImpl? elseStatement,
}) : _condition = condition, }) : _expression = expression,
_thenStatement = thenStatement, _thenStatement = thenStatement,
_elseStatement = elseStatement { _elseStatement = elseStatement {
_becomeParentOf(_condition); _becomeParentOf(_expression);
_becomeParentOf(caseClause); _becomeParentOf(caseClause);
_becomeParentOf(_thenStatement); _becomeParentOf(_thenStatement);
_becomeParentOf(_elseStatement); _becomeParentOf(_elseStatement);
@ -6967,11 +6968,12 @@ class IfStatementImpl extends StatementImpl
@override @override
Token get beginToken => ifKeyword; Token get beginToken => ifKeyword;
@Deprecated('Use expression instead')
@override @override
ExpressionImpl get condition => _condition; ExpressionImpl get condition => _expression;
set condition(ExpressionImpl condition) { set condition(ExpressionImpl condition) {
_condition = _becomeParentOf(condition); _expression = _becomeParentOf(condition);
} }
@override @override
@ -6990,7 +6992,7 @@ class IfStatementImpl extends StatementImpl
} }
@override @override
ExpressionImpl get expression => _condition; ExpressionImpl get expression => _expression;
@override @override
StatementImpl? get ifFalse => elseStatement; StatementImpl? get ifFalse => elseStatement;
@ -7009,7 +7011,7 @@ class IfStatementImpl extends StatementImpl
ChildEntities get _childEntities => ChildEntities() ChildEntities get _childEntities => ChildEntities()
..addToken('ifKeyword', ifKeyword) ..addToken('ifKeyword', ifKeyword)
..addToken('leftParenthesis', leftParenthesis) ..addToken('leftParenthesis', leftParenthesis)
..addNode('condition', condition) ..addNode('expression', expression)
..addNode('caseClause', caseClause) ..addNode('caseClause', caseClause)
..addToken('rightParenthesis', rightParenthesis) ..addToken('rightParenthesis', rightParenthesis)
..addNode('thenStatement', thenStatement) ..addNode('thenStatement', thenStatement)
@ -7021,7 +7023,7 @@ class IfStatementImpl extends StatementImpl
@override @override
void visitChildren(AstVisitor visitor) { void visitChildren(AstVisitor visitor) {
_condition.accept(visitor); _expression.accept(visitor);
caseClause?.accept(visitor); caseClause?.accept(visitor);
_thenStatement.accept(visitor); _thenStatement.accept(visitor);
_elseStatement?.accept(visitor); _elseStatement?.accept(visitor);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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