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>
diff --git a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
index c8c404c..98cb160 100644
--- a/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
+++ b/pkg/analysis_server/lib/src/services/completion/dart/keyword_contributor.dart
@@ -648,7 +648,7 @@
} 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 @@
}
} else if (entity == node.thenStatement || entity == node.elseStatement) {
_addStatementKeywords(node);
- } else if (entity == node.condition) {
+ } else if (entity == node.expression) {
_addExpressionKeywords(node);
}
}
diff --git a/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart b/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
index 24f0466..4263993 100644
--- a/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
+++ b/pkg/analysis_server/lib/src/services/completion/statement/statement_completion.dart
@@ -795,7 +795,7 @@
var stmt = _KeywordConditionBlockStructure(
node.ifKeyword,
node.leftParenthesis,
- node.condition,
+ node.expression,
node.rightParenthesis,
node.thenStatement);
return _complete_ifOrWhileStatement(
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart b/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart
index 56f8948..d1725e8 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/abstract_producer.dart
@@ -195,7 +195,7 @@
// if ( myFunction() ) {}
if (parent is IfStatement) {
var statement = parent;
- if (statement.condition == expression) {
+ if (statement.expression == expression) {
return coreTypeBool;
}
}
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_case_statement.dart b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_case_statement.dart
index 66f159a..7f911b3 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_case_statement.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/convert_to_if_case_statement.dart
@@ -68,7 +68,7 @@
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 @@
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 @@
final initializerCode = utils.getNodeText(initializer);
builder.addSimpleReplacement(
- range.node(ifStatement.condition),
+ range.node(ifStatement.expression),
'$initializerCode case $patternCode',
);
});
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/extract_local_variable.dart b/pkg/analysis_server/lib/src/services/correction/dart/extract_local_variable.dart
index 706d0b4..c11df6e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/extract_local_variable.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/extract_local_variable.dart
@@ -92,7 +92,7 @@
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) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/introduce_local_cast_type.dart b/pkg/analysis_server/lib/src/services/correction/dart/introduce_local_cast_type.dart
index d180777..cc41c9b 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/introduce_local_cast_type.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/introduce_local_cast_type.dart
@@ -89,14 +89,14 @@
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;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/invert_if_statement.dart b/pkg/analysis_server/lib/src/services/correction/dart/invert_if_statement.dart
index c46421a..a93977c 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/invert_if_statement.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/invert_if_statement.dart
@@ -19,7 +19,7 @@
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;
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_inner.dart b/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_inner.dart
index 2e18a4e..5ca3958 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_inner.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_inner.dart
@@ -38,8 +38,8 @@
// 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)) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_outer.dart b/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_outer.dart
index d6a0857..87d3750 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_outer.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/join_if_with_outer.dart
@@ -44,8 +44,8 @@
// 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)) {
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/replace_if_else_with_conditional.dart b/pkg/analysis_server/lib/src/services/correction/dart/replace_if_else_with_conditional.dart
index 3b44a21..fd2793e 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/replace_if_else_with_conditional.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/replace_if_else_with_conditional.dart
@@ -37,7 +37,7 @@
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 @@
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),
diff --git a/pkg/analysis_server/lib/src/services/correction/dart/split_and_condition.dart b/pkg/analysis_server/lib/src/services/correction/dart/split_and_condition.dart
index 41b23dc..24a29d9 100644
--- a/pkg/analysis_server/lib/src/services/correction/dart/split_and_condition.dart
+++ b/pkg/analysis_server/lib/src/services/correction/dart/split_and_condition.dart
@@ -46,7 +46,7 @@
TokenType.AMPERSAND_AMPERSAND) {
condition = condition.parent as BinaryExpression;
}
- if (ifStatement.condition != condition) {
+ if (ifStatement.expression != condition) {
return;
}
// prepare environment
diff --git a/pkg/analysis_server/test/services/correction/util_test.dart b/pkg/analysis_server/test/services/correction/util_test.dart
index 8aa1ba5..a7496bf 100644
--- a/pkg/analysis_server/test/services/correction/util_test.dart
+++ b/pkg/analysis_server/test/services/correction/util_test.dart
@@ -35,7 +35,7 @@
}
''');
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.
diff --git a/pkg/analysis_server/tool/code_completion/code_metrics.dart b/pkg/analysis_server/tool/code_completion/code_metrics.dart
index 6c5b6ad..a97b288 100644
--- a/pkg/analysis_server/tool/code_completion/code_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/code_metrics.dart
@@ -755,7 +755,7 @@
@override
void visitIfElement(IfElement node) {
_visitChildren(node, {
- 'condition': node.condition,
+ 'condition': node.expression,
'thenElement': node.thenElement,
'elseElement': node.elseElement,
});
@@ -765,7 +765,7 @@
@override
void visitIfStatement(IfStatement node) {
_visitChildren(node, {
- 'condition': node.condition,
+ 'condition': node.expression,
'thenStatement': node.thenStatement,
'elseStatement': node.elseStatement,
});
diff --git a/pkg/analysis_server/tool/code_completion/relevance_metrics.dart b/pkg/analysis_server/tool/code_completion/relevance_metrics.dart
index 0c00310..7609882 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_metrics.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_metrics.dart
@@ -825,7 +825,7 @@
@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 @@
@override
void visitIfStatement(IfStatement node) {
- _recordDataForNode('IfStatement (condition)', node.condition,
+ _recordDataForNode('IfStatement (condition)', node.expression,
allowedKeywords: expressionKeywords);
_recordDataForNode('IfStatement (then)', node.thenStatement,
allowedKeywords: statementKeywords);
diff --git a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
index e052c82..6663ae9 100644
--- a/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
+++ b/pkg/analysis_server/tool/code_completion/relevance_table_generator.dart
@@ -798,7 +798,7 @@
@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 @@
@override
void visitIfStatement(IfStatement node) {
- _recordDataForNode('IfStatement_condition', node.condition,
+ _recordDataForNode('IfStatement_condition', node.expression,
allowedKeywords: expressionKeywords);
_recordDataForNode('IfStatement_thenStatement', node.thenStatement,
allowedKeywords: statementKeywords);
diff --git a/pkg/analyzer/CHANGELOG.md b/pkg/analyzer/CHANGELOG.md
index 1bf98cf..2be99fa 100644
--- a/pkg/analyzer/CHANGELOG.md
+++ b/pkg/analyzer/CHANGELOG.md
@@ -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`.
diff --git a/pkg/analyzer/lib/dart/ast/ast.dart b/pkg/analyzer/lib/dart/ast/ast.dart
index 5a2b3a7..a2633e0 100644
--- a/pkg/analyzer/lib/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/dart/ast/ast.dart
@@ -3011,12 +3011,12 @@
///
/// 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 @@
///
/// 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
diff --git a/pkg/analyzer/lib/fix_data.yaml b/pkg/analyzer/lib/fix_data.yaml
index 79af490..4b73002 100644
--- a/pkg/analyzer/lib/fix_data.yaml
+++ b/pkg/analyzer/lib/fix_data.yaml
@@ -144,7 +144,7 @@
newName: 'isAccessibleIn'
# buildSdkSummary()
- - title: "Replace with get buildSdkSummary()"
+ - title: "Replace with buildSdkSummary()"
date: 2022-10-24
element:
function: 'buildSdkSummary2'
@@ -152,3 +152,23 @@
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'
diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart
index 44463bb..31224db3 100644
--- a/pkg/analyzer/lib/src/dart/ast/ast.dart
+++ b/pkg/analyzer/lib/src/dart/ast/ast.dart
@@ -6792,7 +6792,7 @@
@override
final Token leftParenthesis;
- ExpressionImpl _condition;
+ ExpressionImpl _expression;
@override
final CaseClauseImpl? caseClause;
@@ -6814,16 +6814,16 @@
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 @@
@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 @@
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 @@
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 @@
@override
void visitChildren(AstVisitor visitor) {
- condition.accept(visitor);
+ expression.accept(visitor);
caseClause?.accept(visitor);
_thenElement.accept(visitor);
_elseElement?.accept(visitor);
@@ -6926,7 +6927,7 @@
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 @@
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 @@
@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 @@
}
@override
- ExpressionImpl get expression => _condition;
+ ExpressionImpl get expression => _expression;
@override
StatementImpl? get ifFalse => elseStatement;
@@ -7009,7 +7011,7 @@
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 @@
@override
void visitChildren(AstVisitor visitor) {
- _condition.accept(visitor);
+ _expression.accept(visitor);
caseClause?.accept(visitor);
_thenStatement.accept(visitor);
_elseStatement?.accept(visitor);
diff --git a/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart b/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
index 3b6d891..3ee2f1d 100644
--- a/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
+++ b/pkg/analyzer/lib/src/dart/ast/to_source_visitor.dart
@@ -674,7 +674,7 @@
@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 @@
@override
void visitIfStatement(IfStatement node) {
sink.write('if (');
- _visitNode(node.condition);
+ _visitNode(node.expression);
_visitNode(node.caseClause, prefix: ' ');
sink.write(') ');
_visitNode(node.thenStatement);
diff --git a/pkg/analyzer/lib/src/dart/ast/utilities.dart b/pkg/analyzer/lib/src/dart/ast/utilities.dart
index 69336f4..7762d85 100644
--- a/pkg/analyzer/lib/src/dart/ast/utilities.dart
+++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart
@@ -781,7 +781,7 @@
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 @@
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 @@
@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 @@
@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)) {
diff --git a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
index b26128f..d5b3efe 100644
--- a/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
+++ b/pkg/analyzer/lib/src/dart/constant/constant_verifier.dart
@@ -1004,7 +1004,7 @@
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.
diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
index 541081e..b4ee663 100644
--- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart
+++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart
@@ -1185,7 +1185,7 @@
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 @@
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 @@
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 @@
} 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) {
diff --git a/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart b/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
index c988dc5..6959729 100644
--- a/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
+++ b/pkg/analyzer/lib/src/dart/constant/potentially_constant.dart
@@ -183,7 +183,7 @@
}
if (node is IfElement) {
- collect(node.condition);
+ collect(node.expression);
collect(node.thenElement);
if (node.elseElement != null) {
collect(node.elseElement!);
diff --git a/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart b/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart
index 1aca5b8..9e26ba6 100644
--- a/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart
+++ b/pkg/analyzer/lib/src/dart/resolver/exit_detector.dart
@@ -322,7 +322,7 @@
@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 @@
@override
bool visitIfStatement(IfStatement node) {
- var conditionExpression = node.condition;
+ var conditionExpression = node.expression;
var thenStatement = node.thenStatement;
var elseStatement = node.elseStatement;
if (_nodeExits(conditionExpression)) {
diff --git a/pkg/analyzer/lib/src/error/best_practices_verifier.dart b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
index 0094627..e2e26cc 100644
--- a/pkg/analyzer/lib/src/error/best_practices_verifier.dart
+++ b/pkg/analyzer/lib/src/error/best_practices_verifier.dart
@@ -1286,7 +1286,7 @@
}
// 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 ||
diff --git a/pkg/analyzer/lib/src/error/dead_code_verifier.dart b/pkg/analyzer/lib/src/error/dead_code_verifier.dart
index 70975a7..646303d 100644
--- a/pkg/analyzer/lib/src/error/dead_code_verifier.dart
+++ b/pkg/analyzer/lib/src/error/dead_code_verifier.dart
@@ -234,7 +234,7 @@
@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 @@
@override
void visitIfStatement(IfStatement node) {
- Expression conditionExpression = node.condition;
+ Expression conditionExpression = node.expression;
conditionExpression.accept(this);
if (!_isDebugConstant(conditionExpression)) {
var result = _getConstantBooleanValue(conditionExpression);
diff --git a/pkg/analyzer/lib/src/fasta/ast_builder.dart b/pkg/analyzer/lib/src/fasta/ast_builder.dart
index 93b79cd..2e0acbd 100644
--- a/pkg/analyzer/lib/src/fasta/ast_builder.dart
+++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart
@@ -2248,7 +2248,7 @@
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
- condition: condition.expression,
+ expression: condition.expression,
caseClause: condition.caseClause,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
@@ -2269,7 +2269,7 @@
IfElementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
- condition: condition.expression,
+ expression: condition.expression,
caseClause: condition.caseClause,
rightParenthesis: condition.rightParenthesis,
thenElement: thenElement,
@@ -2291,7 +2291,7 @@
IfStatementImpl(
ifKeyword: ifToken,
leftParenthesis: condition.leftParenthesis,
- condition: condition.expression,
+ expression: condition.expression,
caseClause: condition.caseClause,
rightParenthesis: condition.rightParenthesis,
thenStatement: thenPart,
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
index 403b930..ff80ea0 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart
@@ -654,11 +654,11 @@
}
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,
diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
index ac37e52..328ca372 100644
--- a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
+++ b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart
@@ -341,7 +341,7 @@
@override
void visitIfElement(IfElement node) {
_writeByte(Tag.IfElement);
- _writeNode(node.condition);
+ _writeNode(node.expression);
_writeNode(node.thenElement);
_writeOptionalNode(node.elseElement);
}
diff --git a/pkg/analyzer/test/generated/class_member_parser_test.dart b/pkg/analyzer/test/generated/class_member_parser_test.dart
index b4a6656..0ffd181 100644
--- a/pkg/analyzer/test/generated/class_member_parser_test.dart
+++ b/pkg/analyzer/test/generated/class_member_parser_test.dart
@@ -187,12 +187,12 @@
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;
diff --git a/pkg/analyzer/test/generated/collection_literal_parser_test.dart b/pkg/analyzer/test/generated/collection_literal_parser_test.dart
index 2a65303..bbb5dea 100644
--- a/pkg/analyzer/test/generated/collection_literal_parser_test.dart
+++ b/pkg/analyzer/test/generated/collection_literal_parser_test.dart
@@ -76,7 +76,7 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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 @@
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, '...');
diff --git a/pkg/analyzer/test/generated/patterns_parser_test.dart b/pkg/analyzer/test/generated/patterns_parser_test.dart
index aaf0baa..502df51 100644
--- a/pkg/analyzer/test/generated/patterns_parser_test.dart
+++ b/pkg/analyzer/test/generated/patterns_parser_test.dart
@@ -61,7 +61,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -90,7 +90,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -122,7 +122,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -152,7 +152,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -215,7 +215,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -240,7 +240,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -268,7 +268,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -319,7 +319,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -353,7 +353,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -390,7 +390,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -459,7 +459,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -489,7 +489,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -522,7 +522,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -3243,7 +3243,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
@@ -3281,7 +3281,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
caseClause: CaseClause
caseKeyword: case
diff --git a/pkg/analyzer/test/generated/recovery_parser_test.dart b/pkg/analyzer/test/generated/recovery_parser_test.dart
index 7ae5b52..265cca0 100644
--- a/pkg/analyzer/test/generated/recovery_parser_test.dart
+++ b/pkg/analyzer/test/generated/recovery_parser_test.dart
@@ -1077,7 +1077,7 @@
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);
diff --git a/pkg/analyzer/test/generated/statement_parser_test.dart b/pkg/analyzer/test/generated/statement_parser_test.dart
index 8bc6770..fd9a8e6 100644
--- a/pkg/analyzer/test/generated/statement_parser_test.dart
+++ b/pkg/analyzer/test/generated/statement_parser_test.dart
@@ -875,7 +875,7 @@
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 @@
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 @@
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 @@
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 @@
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);
diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart
index af345be..7feb3dc 100644
--- a/pkg/analyzer/test/generated/utilities_test.dart
+++ b/pkg/analyzer/test/generated/utilities_test.dart
@@ -1114,7 +1114,7 @@
destination: findNode.ifStatement('true'),
source: findNode.ifStatement('false'),
childAccessors: [
- (node) => node.condition,
+ (node) => node.expression,
(node) => node.thenStatement,
(node) => node.elseStatement!,
],
diff --git a/pkg/analyzer/test/src/dart/resolution/if_element_test.dart b/pkg/analyzer/test/src/dart/resolution/if_element_test.dart
index c1a4cd2..3b09e8b 100644
--- a/pkg/analyzer/test/src/dart/resolution/if_element_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/if_element_test.dart
@@ -28,7 +28,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@@ -62,7 +62,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@getter::x
staticType: int
@@ -112,7 +112,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@@ -191,7 +191,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@@ -254,7 +254,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SuperExpression
+ expression: SuperExpression
superKeyword: super
staticType: A
rightParenthesis: )
@@ -284,7 +284,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@@ -326,7 +326,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: FunctionExpressionInvocation
+ expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@@ -356,7 +356,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: FunctionExpressionInvocation
+ expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@@ -394,7 +394,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
@@ -438,7 +438,7 @@
IfElement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object
diff --git a/pkg/analyzer/test/src/dart/resolution/if_statement_test.dart b/pkg/analyzer/test/src/dart/resolution/if_statement_test.dart
index 664e2a8..29d9ff9 100644
--- a/pkg/analyzer/test/src/dart/resolution/if_statement_test.dart
+++ b/pkg/analyzer/test/src/dart/resolution/if_statement_test.dart
@@ -28,7 +28,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
@@ -61,7 +61,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -144,7 +144,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -228,7 +228,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -313,7 +313,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -397,7 +397,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -476,7 +476,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -559,7 +559,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -650,7 +650,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -736,7 +736,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -815,7 +815,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -912,7 +912,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -1006,7 +1006,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -1082,7 +1082,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: Object?
@@ -1157,7 +1157,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SuperExpression
+ expression: SuperExpression
superKeyword: super
staticType: A
rightParenthesis: )
@@ -1183,7 +1183,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
@@ -1225,7 +1225,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: FunctionExpressionInvocation
+ expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@@ -1255,7 +1255,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: FunctionExpressionInvocation
+ expression: FunctionExpressionInvocation
function: SimpleIdentifier
token: a
staticElement: self::@function::f::@parameter::a
@@ -1293,7 +1293,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
@@ -1337,7 +1337,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: dynamic
diff --git a/pkg/analyzer/test/src/diagnostics/duplicate_variable_pattern_test.dart b/pkg/analyzer/test/src/diagnostics/duplicate_variable_pattern_test.dart
index 809df08..7f53cb5 100644
--- a/pkg/analyzer/test/src/diagnostics/duplicate_variable_pattern_test.dart
+++ b/pkg/analyzer/test/src/diagnostics/duplicate_variable_pattern_test.dart
@@ -31,7 +31,7 @@
IfStatement
ifKeyword: if
leftParenthesis: (
- condition: SimpleIdentifier
+ expression: SimpleIdentifier
token: x
staticElement: self::@function::f::@parameter::x
staticType: int
diff --git a/pkg/analyzer/test/src/summary/elements_test.dart b/pkg/analyzer/test/src/summary/elements_test.dart
index 7f7a5f6..4fde7b3 100644
--- a/pkg/analyzer/test/src/summary/elements_test.dart
+++ b/pkg/analyzer/test/src/summary/elements_test.dart
@@ -15207,7 +15207,7 @@
IfElement
ifKeyword: if @29
leftParenthesis: ( @32
- condition: BooleanLiteral
+ expression: BooleanLiteral
literal: true @33
staticType: bool
rightParenthesis: ) @37
@@ -15251,7 +15251,7 @@
IfElement
ifKeyword: if @29
leftParenthesis: ( @32
- condition: BooleanLiteral
+ expression: BooleanLiteral
literal: true @33
staticType: bool
rightParenthesis: ) @37
@@ -15443,7 +15443,7 @@
IfElement
ifKeyword: if @34
leftParenthesis: ( @37
- condition: BooleanLiteral
+ expression: BooleanLiteral
literal: true @38
staticType: bool
rightParenthesis: ) @42
@@ -17259,7 +17259,7 @@
IfElement
ifKeyword: if @29
leftParenthesis: ( @32
- condition: BooleanLiteral
+ expression: BooleanLiteral
literal: true @33
staticType: bool
rightParenthesis: ) @37
diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
index 4303bc3..080af05 100644
--- a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
+++ b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart
@@ -927,7 +927,7 @@
@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 @@
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;
diff --git a/pkg/nnbd_migration/lib/src/edge_builder.dart b/pkg/nnbd_migration/lib/src/edge_builder.dart
index 26d1256..2b0c9c6 100644
--- a/pkg/nnbd_migration/lib/src/edge_builder.dart
+++ b/pkg/nnbd_migration/lib/src/edge_builder.dart
@@ -1117,11 +1117,11 @@
@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 @@
@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 @@
_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));
diff --git a/pkg/nnbd_migration/lib/src/fix_aggregator.dart b/pkg/nnbd_migration/lib/src/fix_aggregator.dart
index 8a071dd..31609d6 100644
--- a/pkg/nnbd_migration/lib/src/fix_aggregator.dart
+++ b/pkg/nnbd_migration/lib/src/fix_aggregator.dart
@@ -889,8 +889,8 @@
@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 @@
@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);
}
diff --git a/pkg/scrape/example/null_aware.dart b/pkg/scrape/example/null_aware.dart
index d2902c2..b514114 100644
--- a/pkg/scrape/example/null_aware.dart
+++ b/pkg/scrape/example/null_aware.dart
@@ -272,7 +272,7 @@
}
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) {