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 c8c404c9c5c..98cb160b43b 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 @@ class _KeywordVisitor extends GeneralizingAstVisitor { } else if (entity == node.thenElement || entity == node.elseElement) { _addCollectionElementKeywords(); _addExpressionKeywords(node); - } else if (entity == node.condition) { + } else if (entity == node.expression) { _addExpressionKeywords(node); } return super.visitIfElement(node); @@ -675,7 +675,7 @@ class _KeywordVisitor extends GeneralizingAstVisitor { } } 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 24f04661580..426399399ea 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 @@ class StatementCompletionProcessor { 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 56f89486841..d1725e86e04 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 @@ abstract class CorrectionProducer extends SingleCorrectionProducer { // 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 66f159ab37c..7f911b36a15 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 @@ class ConvertToIfCaseStatement extends CorrectionProducer { required IfStatement ifStatement, required bool Function() hasReferencesAfterThen, }) async { - final isExpression = ifStatement.condition; + final isExpression = ifStatement.expression; if (isExpression is! IsExpression) { return; } @@ -106,7 +106,7 @@ class ConvertToIfCaseStatement extends CorrectionProducer { required IfStatement ifStatement, required bool Function() hasReferencesAfterThen, }) async { - final notEqNull = ifStatement.condition; + final notEqNull = ifStatement.expression; if (notEqNull is! BinaryExpression) { return; } @@ -158,7 +158,7 @@ class ConvertToIfCaseStatement extends CorrectionProducer { final initializerCode = utils.getNodeText(initializer); builder.addSimpleReplacement( - range.node(ifStatement.condition), + range.node(ifStatement.expression), '$initializerCode case $patternCode', ); }); 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 706d0b440a3..c11df6e537b 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 @@ class ExtractLocalVariable extends CorrectionProducer { return; } if (enclosingNode is IfStatement) { - var condition = enclosingNode.condition; + var condition = enclosingNode.expression; if (condition is BinaryExpression && condition.rightOperand is NullLiteral && condition.operator.type == TokenType.BANG_EQ) { 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 d180777b7d7..cc41c9b4f88 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 @@ class IntroduceLocalCastType extends CorrectionProducer { static Expression? _getCondition(AstNode node) { if (node is IfStatement) { - return node.condition; + return node.expression; } else if (node is WhileStatement) { return node.condition; } if (node is Expression) { var parent = node.parent; - if (parent is IfStatement && parent.condition == node) { + if (parent is IfStatement && parent.expression == node) { return node; } else if (parent is WhileStatement && parent.condition == node) { return node; 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 c46421a4592..a93977c757b 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 @@ class InvertIfStatement extends CorrectionProducer { if (ifStatement is! IfStatement) { return; } - var condition = ifStatement.condition; + var condition = ifStatement.expression; // should have both "then" and "else" var thenStatement = ifStatement.thenStatement; var elseStatement = ifStatement.elseStatement; 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 2e18a4e4202..5ca3958de0f 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 @@ class JoinIfWithInner extends CorrectionProducer { // prepare environment var prefix = utils.getNodePrefix(targetIfStatement); // merge conditions - var targetCondition = targetIfStatement.condition; - var innerCondition = innerIfStatement.condition; + var targetCondition = targetIfStatement.expression; + var innerCondition = innerIfStatement.expression; var targetConditionSource = utils.getNodeText(targetCondition); var innerConditionSource = utils.getNodeText(innerCondition); if (shouldWrapParenthesisBeforeAnd(targetCondition)) { 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 d6a0857cd43..87d3750e823 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 @@ class JoinIfWithOuter extends CorrectionProducer { // prepare environment var prefix = utils.getNodePrefix(outerIfStatement); // merge conditions - var targetCondition = targetIfStatement.condition; - var outerCondition = outerIfStatement.condition; + var targetCondition = targetIfStatement.expression; + var outerCondition = outerIfStatement.expression; var targetConditionSource = utils.getNodeText(targetCondition); var outerConditionSource = utils.getNodeText(outerCondition); if (shouldWrapParenthesisBeforeAnd(targetCondition)) { 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 3b44a21fff5..fd2793e5dce 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 @@ class ReplaceIfElseWithConditional extends CorrectionProducer { var elseExpression = elseStatement.expression; if (thenExpression != null && elseExpression != null) { await builder.addDartFileEdit(file, (builder) { - var conditionSrc = utils.getNodeText(ifStatement.condition); + var conditionSrc = utils.getNodeText(ifStatement.expression); var thenSrc = utils.getNodeText(thenExpression); var elseSrc = utils.getNodeText(elseExpression); builder.addSimpleReplacement(range.node(ifStatement), @@ -58,7 +58,7 @@ class ReplaceIfElseWithConditional extends CorrectionProducer { if (thenAssignment.operator.type == TokenType.EQ && elseAssignment.operator.type == TokenType.EQ && thenTarget == elseTarget) { - var conditionSrc = utils.getNodeText(ifStatement.condition); + var conditionSrc = utils.getNodeText(ifStatement.expression); var thenSrc = utils.getNodeText(thenAssignment.rightHandSide); var elseSrc = utils.getNodeText(elseAssignment.rightHandSide); builder.addSimpleReplacement(range.node(ifStatement), 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 41b23dc1e03..24a29d9a789 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 @@ class SplitAndCondition extends CorrectionProducer { 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 8aa1ba59d19..a7496bf7921 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 @@ void f(bool? b4, bool? b5) { } '''); var ifStatement = findNode.ifStatement('if ('); - var condition = ifStatement.condition; + var condition = ifStatement.expression; var result = CorrectionUtils(testAnalysisResult).invertCondition(condition); expect(result, expected); // For compactness we put multiple cases into one test method. diff --git a/pkg/analysis_server/tool/code_completion/code_metrics.dart b/pkg/analysis_server/tool/code_completion/code_metrics.dart index 6c5b6ad678b..a97b288f182 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 @@ class CodeShapeDataCollector extends RecursiveAstVisitor { @override void visitIfElement(IfElement node) { _visitChildren(node, { - 'condition': node.condition, + 'condition': node.expression, 'thenElement': node.thenElement, 'elseElement': node.elseElement, }); @@ -765,7 +765,7 @@ class CodeShapeDataCollector extends RecursiveAstVisitor { @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 0c00310f979..7609882cdc7 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 @@ class RelevanceDataCollector extends RecursiveAstVisitor { @override void visitIfElement(IfElement node) { - _recordDataForNode('IfElement (condition)', node.condition, + _recordDataForNode('IfElement (condition)', node.expression, allowedKeywords: expressionKeywords); _recordDataForNode('IfElement (then)', node.thenElement); _recordDataForNode('IfElement (else)', node.elseElement); @@ -834,7 +834,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor { @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 e052c822e3a..6663ae96468 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 @@ class RelevanceDataCollector extends RecursiveAstVisitor { @override void visitIfElement(IfElement node) { - _recordDataForNode('IfElement_condition', node.condition, + _recordDataForNode('IfElement_condition', node.expression, allowedKeywords: expressionKeywords); _recordDataForNode('IfElement_thenElement', node.thenElement); _recordDataForNode('IfElement_elseElement', node.elseElement); @@ -807,7 +807,7 @@ class RelevanceDataCollector extends RecursiveAstVisitor { @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 1bf98cfc9d4..2be99fa9217 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 5a2b3a759f0..a2633e01e55 100644 --- a/pkg/analyzer/lib/dart/ast/ast.dart +++ b/pkg/analyzer/lib/dart/ast/ast.dart @@ -3011,12 +3011,12 @@ abstract class Identifier implements Expression, CommentReferableExpression { /// /// Clients may not extend, implement or mix-in this class. abstract class IfElement implements CollectionElement { - /// Return the `case` clause used to match a pattern against the [condition]. + /// Return the `case` clause used to match a pattern against the [expression]. CaseClause? get caseClause; /// Return the condition used to determine which of the statements is executed /// next. - // TODO(brianwilkerson) Deprecate this when the patterns feature is released. + @Deprecated('Use expression instead') Expression get condition; /// Return the statement that is executed if the condition evaluates to @@ -3054,12 +3054,12 @@ abstract class IfElement implements CollectionElement { /// /// Clients may not extend, implement or mix-in this class. abstract class IfStatement implements Statement { - /// Return the `case` clause used to match a pattern against the [condition]. + /// Return the `case` clause used to match a pattern against the [expression]. CaseClause? get caseClause; /// Return the condition used to determine which of the statements is executed /// next. - // TODO(brianwilkerson) Deprecate this when the patterns feature is released. + @Deprecated('Use expression instead') Expression get condition; /// Return the token representing the 'else' keyword, or `null` if there is no diff --git a/pkg/analyzer/lib/fix_data.yaml b/pkg/analyzer/lib/fix_data.yaml index 79af490fd8e..4b7300276ad 100644 --- a/pkg/analyzer/lib/fix_data.yaml +++ b/pkg/analyzer/lib/fix_data.yaml @@ -144,7 +144,7 @@ transforms: newName: 'isAccessibleIn' # buildSdkSummary() - - title: "Replace with get buildSdkSummary()" + - title: "Replace with buildSdkSummary()" date: 2022-10-24 element: function: 'buildSdkSummary2' @@ -152,3 +152,23 @@ transforms: changes: - kind: 'rename' newName: 'buildSdkSummary' + + # condition -> expression + - title: "Replace with get expression" + date: 2023-04-18 + element: + method: 'condition' + uris: [ 'package:analyzer/dart/ast/ast.dart' ] + inClass: 'IfStatement' + changes: + - kind: rename + newName: 'expression' + - title: "Replace with get expression" + date: 2023-04-18 + element: + method: 'condition' + uris: [ 'package:analyzer/dart/ast/ast.dart' ] + inClass: 'IfElement' + changes: + - kind: rename + newName: 'expression' diff --git a/pkg/analyzer/lib/src/dart/ast/ast.dart b/pkg/analyzer/lib/src/dart/ast/ast.dart index 44463bb875f..31224db32d4 100644 --- a/pkg/analyzer/lib/src/dart/ast/ast.dart +++ b/pkg/analyzer/lib/src/dart/ast/ast.dart @@ -6792,7 +6792,7 @@ class IfElementImpl extends CollectionElementImpl @override final Token leftParenthesis; - ExpressionImpl _condition; + ExpressionImpl _expression; @override final CaseClauseImpl? caseClause; @@ -6814,16 +6814,16 @@ class IfElementImpl extends CollectionElementImpl IfElementImpl({ required this.ifKeyword, required this.leftParenthesis, - required ExpressionImpl condition, + required ExpressionImpl expression, required this.caseClause, required this.rightParenthesis, required CollectionElementImpl thenElement, required this.elseKeyword, required CollectionElementImpl? elseElement, - }) : _condition = condition, + }) : _expression = expression, _thenElement = thenElement, _elseElement = elseElement { - _becomeParentOf(_condition); + _becomeParentOf(_expression); _becomeParentOf(caseClause); _becomeParentOf(_thenElement); _becomeParentOf(_elseElement); @@ -6832,11 +6832,12 @@ class IfElementImpl extends CollectionElementImpl @override Token get beginToken => ifKeyword; + @Deprecated('Use expression instead') @override - ExpressionImpl get condition => _condition; + ExpressionImpl get condition => _expression; set condition(ExpressionImpl condition) { - _condition = _becomeParentOf(condition); + _expression = _becomeParentOf(condition); } @override @@ -6850,7 +6851,7 @@ class IfElementImpl extends CollectionElementImpl Token get endToken => _elseElement?.endToken ?? _thenElement.endToken; @override - ExpressionImpl get expression => _condition; + ExpressionImpl get expression => _expression; @override CollectionElementImpl? get ifFalse => elseElement; @@ -6869,7 +6870,7 @@ class IfElementImpl extends CollectionElementImpl ChildEntities get _childEntities => ChildEntities() ..addToken('ifKeyword', ifKeyword) ..addToken('leftParenthesis', leftParenthesis) - ..addNode('condition', condition) + ..addNode('expression', expression) ..addNode('caseClause', caseClause) ..addToken('rightParenthesis', rightParenthesis) ..addNode('thenElement', thenElement) @@ -6888,7 +6889,7 @@ class IfElementImpl extends CollectionElementImpl @override void visitChildren(AstVisitor visitor) { - condition.accept(visitor); + expression.accept(visitor); caseClause?.accept(visitor); _thenElement.accept(visitor); _elseElement?.accept(visitor); @@ -6926,7 +6927,7 @@ class IfStatementImpl extends StatementImpl final Token leftParenthesis; /// The condition used to determine which of the branches is executed next. - ExpressionImpl _condition; + ExpressionImpl _expression; @override final CaseClauseImpl? caseClause; @@ -6949,16 +6950,16 @@ class IfStatementImpl extends StatementImpl IfStatementImpl({ required this.ifKeyword, required this.leftParenthesis, - required ExpressionImpl condition, + required ExpressionImpl expression, required this.caseClause, required this.rightParenthesis, required StatementImpl thenStatement, required this.elseKeyword, required StatementImpl? elseStatement, - }) : _condition = condition, + }) : _expression = expression, _thenStatement = thenStatement, _elseStatement = elseStatement { - _becomeParentOf(_condition); + _becomeParentOf(_expression); _becomeParentOf(caseClause); _becomeParentOf(_thenStatement); _becomeParentOf(_elseStatement); @@ -6967,11 +6968,12 @@ class IfStatementImpl extends StatementImpl @override Token get beginToken => ifKeyword; + @Deprecated('Use expression instead') @override - ExpressionImpl get condition => _condition; + ExpressionImpl get condition => _expression; set condition(ExpressionImpl condition) { - _condition = _becomeParentOf(condition); + _expression = _becomeParentOf(condition); } @override @@ -6990,7 +6992,7 @@ class IfStatementImpl extends StatementImpl } @override - ExpressionImpl get expression => _condition; + ExpressionImpl get expression => _expression; @override StatementImpl? get ifFalse => elseStatement; @@ -7009,7 +7011,7 @@ class IfStatementImpl extends StatementImpl ChildEntities get _childEntities => ChildEntities() ..addToken('ifKeyword', ifKeyword) ..addToken('leftParenthesis', leftParenthesis) - ..addNode('condition', condition) + ..addNode('expression', expression) ..addNode('caseClause', caseClause) ..addToken('rightParenthesis', rightParenthesis) ..addNode('thenStatement', thenStatement) @@ -7021,7 +7023,7 @@ class IfStatementImpl extends StatementImpl @override void visitChildren(AstVisitor visitor) { - _condition.accept(visitor); + _expression.accept(visitor); caseClause?.accept(visitor); _thenStatement.accept(visitor); _elseStatement?.accept(visitor); 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 3b6d891ff36..3ee2f1d9d97 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 @@ class ToSourceVisitor implements AstVisitor { @override void visitIfElement(IfElement node) { sink.write('if ('); - _visitNode(node.condition); + _visitNode(node.expression); _visitNode(node.caseClause, prefix: ' '); sink.write(') '); _visitNode(node.thenElement); @@ -684,7 +684,7 @@ class ToSourceVisitor implements AstVisitor { @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 69336f4d841..7762d8596d9 100644 --- a/pkg/analyzer/lib/src/dart/ast/utilities.dart +++ b/pkg/analyzer/lib/src/dart/ast/utilities.dart @@ -781,7 +781,7 @@ class AstComparator implements AstVisitor { IfElement other = _other as IfElement; return isEqualTokens(node.ifKeyword, other.ifKeyword) && isEqualTokens(node.leftParenthesis, other.leftParenthesis) && - isEqualNodes(node.condition, other.condition) && + isEqualNodes(node.expression, other.expression) && isEqualTokens(node.rightParenthesis, other.rightParenthesis) && isEqualNodes(node.thenElement, other.thenElement) && isEqualTokens(node.elseKeyword, other.elseKeyword) && @@ -793,7 +793,7 @@ class AstComparator implements AstVisitor { IfStatement other = _other as IfStatement; return isEqualTokens(node.ifKeyword, other.ifKeyword) && isEqualTokens(node.leftParenthesis, other.leftParenthesis) && - isEqualNodes(node.condition, other.condition) && + isEqualNodes(node.expression, other.expression) && isEqualTokens(node.rightParenthesis, other.rightParenthesis) && isEqualNodes(node.thenStatement, other.thenStatement) && isEqualTokens(node.elseKeyword, other.elseKeyword) && @@ -2720,7 +2720,7 @@ class NodeReplacer extends ThrowingAstVisitor { @override bool visitIfElement(IfElement node) { - if (identical(node.condition, _oldNode)) { + if (identical(node.expression, _oldNode)) { (node as IfElementImpl).condition = _newNode as ExpressionImpl; return true; } else if (identical(node.thenElement, _oldNode)) { @@ -2735,7 +2735,7 @@ class NodeReplacer extends ThrowingAstVisitor { @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 b26128fc648..d5b3efefbb8 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 @@ class _ConstLiteralVerifier { verifier._errorReporter.reportErrorForNode(errorCode, element); return false; } else if (element is IfElement) { - var conditionValue = verifier._validate(element.condition, errorCode); + var conditionValue = verifier._validate(element.expression, errorCode); var conditionBool = conditionValue?.toBoolValue(); // The errors have already been reported. diff --git a/pkg/analyzer/lib/src/dart/constant/evaluation.dart b/pkg/analyzer/lib/src/dart/constant/evaluation.dart index 541081efbc9..b4ee663326e 100644 --- a/pkg/analyzer/lib/src/dart/constant/evaluation.dart +++ b/pkg/analyzer/lib/src/dart/constant/evaluation.dart @@ -1185,7 +1185,7 @@ class ConstantVisitor extends UnifyingAstVisitor { if (element is ForElement) { _error(element, null); } else if (element is IfElement) { - var conditionValue = _evaluateCondition(element.condition); + var conditionValue = _evaluateCondition(element.expression); if (conditionValue == null) { return true; } else if (conditionValue) { @@ -1222,7 +1222,7 @@ class ConstantVisitor extends UnifyingAstVisitor { if (element is ForElement) { _error(element, null); } else if (element is IfElement) { - var conditionValue = _evaluateCondition(element.condition); + var conditionValue = _evaluateCondition(element.expression); if (conditionValue == null) { return true; } else if (conditionValue) { @@ -1259,7 +1259,7 @@ class ConstantVisitor extends UnifyingAstVisitor { if (element is ForElement) { _error(element, null); } else if (element is IfElement) { - var conditionValue = _evaluateCondition(element.condition); + var conditionValue = _evaluateCondition(element.expression); if (conditionValue == null) { return true; } else if (conditionValue) { @@ -1512,7 +1512,7 @@ class ConstantVisitor extends UnifyingAstVisitor { } 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 c988dc593a1..6959729a52c 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 @@ class _Collector { } 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 1aca5b8b365..9e26ba6a29b 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 @@ class ExitDetector extends GeneralizingAstVisitor { @override bool visitIfElement(IfElement node) { - var conditionExpression = node.condition; + var conditionExpression = node.expression; var thenElement = node.thenElement; var elseElement = node.elseElement; if (_nodeExits(conditionExpression)) { @@ -346,7 +346,7 @@ class ExitDetector extends GeneralizingAstVisitor { @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 0094627706b..e2e26cc0023 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 @@ class BestPracticesVerifier extends RecursiveAstVisitor { } // 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 70975a707ec..646303dd77e 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 @@ class LegacyDeadCodeVerifier extends RecursiveAstVisitor { @override void visitIfElement(IfElement node) { - Expression conditionExpression = node.condition; + Expression conditionExpression = node.expression; conditionExpression.accept(this); if (!_isDebugConstant(conditionExpression)) { var result = _getConstantBooleanValue(conditionExpression); @@ -262,7 +262,7 @@ class LegacyDeadCodeVerifier extends RecursiveAstVisitor { @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 93b79cdf389..2e0acbd6279 100644 --- a/pkg/analyzer/lib/src/fasta/ast_builder.dart +++ b/pkg/analyzer/lib/src/fasta/ast_builder.dart @@ -2248,7 +2248,7 @@ class AstBuilder extends StackListener { IfElementImpl( ifKeyword: ifToken, leftParenthesis: condition.leftParenthesis, - condition: condition.expression, + expression: condition.expression, caseClause: condition.caseClause, rightParenthesis: condition.rightParenthesis, thenElement: thenElement, @@ -2269,7 +2269,7 @@ class AstBuilder extends StackListener { IfElementImpl( ifKeyword: ifToken, leftParenthesis: condition.leftParenthesis, - condition: condition.expression, + expression: condition.expression, caseClause: condition.caseClause, rightParenthesis: condition.rightParenthesis, thenElement: thenElement, @@ -2291,7 +2291,7 @@ class AstBuilder extends StackListener { IfStatementImpl( ifKeyword: ifToken, leftParenthesis: condition.leftParenthesis, - condition: condition.expression, + expression: condition.expression, caseClause: condition.caseClause, rightParenthesis: condition.rightParenthesis, thenStatement: thenPart, diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart b/pkg/analyzer/lib/src/summary2/ast_binary_reader.dart index 403b9304b29..ff80ea02eca 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 @@ class AstBinaryReader { } IfElement _readIfElement() { - var condition = readNode() as ExpressionImpl; + var expression = readNode() as ExpressionImpl; var thenElement = readNode() as CollectionElementImpl; var elseElement = _readOptionalNode() as CollectionElementImpl?; return IfElementImpl( - condition: condition, + expression: expression, caseClause: null, elseElement: elseElement, elseKeyword: elseElement != null ? Tokens.else_() : null, diff --git a/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart b/pkg/analyzer/lib/src/summary2/ast_binary_writer.dart index ac37e52bf1e..328ca3725a8 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 @@ class AstBinaryWriter extends ThrowingAstVisitor { @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 b4a6656bcb2..0ffd181ceda 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 @@ class ClassMemberParserTest extends FastaParserTestCase expect(body, isBlockFunctionBody); Statement statement = (body as BlockFunctionBody).block.statements[0]; expect(statement, isIfStatement); - Expression expression = (statement as IfStatement).condition; + Expression expression = (statement as IfStatement).expression; expect(expression, isAwaitExpression); expect(statement.elseStatement, isNotNull); Statement elseStatement = statement.elseStatement!; expect(elseStatement, isIfStatement); - expression = (elseStatement as IfStatement).condition; + expression = (elseStatement as IfStatement).expression; expect(expression, isPrefixExpression); expect((expression as PrefixExpression).operator.lexeme, '!'); expression = expression.operand; diff --git a/pkg/analyzer/test/generated/collection_literal_parser_test.dart b/pkg/analyzer/test/generated/collection_literal_parser_test.dart index 2a6530352cf..bbb5deaa991 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 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(iterable.name, 'list'); var body = second.body as IfElement; - var condition = body.condition as SimpleIdentifier; + var condition = body.expression as SimpleIdentifier; expect(condition.name, 'c'); var thenElement = body.thenElement as IntegerLiteral; expect(thenElement.value, 2); @@ -113,7 +113,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = list.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as IntegerLiteral; expect(thenElement.value, 2); @@ -127,7 +127,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = list.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as IntegerLiteral; expect(thenElement.value, 2); @@ -143,7 +143,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = list.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as IntegerLiteral; expect(thenElement.value, 2); @@ -164,7 +164,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = list.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as SpreadElement; expect(thenElement.spreadOperator.lexeme, '...'); @@ -180,7 +180,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = list.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as ForElement; @@ -199,7 +199,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = list.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as SpreadElement; expect(thenElement.spreadOperator.lexeme, '...'); @@ -272,7 +272,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(iterable.name, 'list'); var body = second.body as IfElement; - var condition = body.condition as SimpleIdentifier; + var condition = body.expression as SimpleIdentifier; expect(condition.name, 'c'); var thenElement = body.thenElement as MapLiteralEntry; var thenValue = thenElement.value as IntegerLiteral; @@ -312,7 +312,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(firstValue.value, 1); var second = map.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as MapLiteralEntry; var thenElementValue = thenElement.value as IntegerLiteral; @@ -329,7 +329,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(firstValue.value, 1); var second = map.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as MapLiteralEntry; var thenElementValue = thenElement.value as IntegerLiteral; @@ -349,7 +349,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(firstValue.value, 1); var second = map.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as MapLiteralEntry; var thenElementValue = thenElement.value as IntegerLiteral; @@ -373,7 +373,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(firstValue.value, 7); var second = map.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as SpreadElement; expect(thenElement.spreadOperator.lexeme, '...'); @@ -395,7 +395,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(firstValue.value, 1); var second = map.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as ForElement; @@ -417,7 +417,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(firstValue.value, 1); var second = map.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as SpreadElement; expect(thenElement.spreadOperator.lexeme, '...'); @@ -508,7 +508,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = setLiteral.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as IntegerLiteral; expect(thenElement.value, 2); @@ -523,7 +523,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = setLiteral.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as IntegerLiteral; expect(thenElement.value, 2); @@ -540,7 +540,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = setLiteral.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as SpreadElement; expect(thenElement.spreadOperator.lexeme, '...'); @@ -560,7 +560,7 @@ class CollectionLiteralParserTest extends FastaParserTestCase { expect(first.value, 1); var second = setLiteral.elements[1] as IfElement; - var condition = second.condition as BooleanLiteral; + var condition = second.expression as BooleanLiteral; expect(condition.value, isTrue); var thenElement = second.thenElement as SpreadElement; expect(thenElement.spreadOperator.lexeme, '...'); diff --git a/pkg/analyzer/test/generated/patterns_parser_test.dart b/pkg/analyzer/test/generated/patterns_parser_test.dart index aaf0baa1458..502df518cd5 100644 --- a/pkg/analyzer/test/generated/patterns_parser_test.dart +++ b/pkg/analyzer/test/generated/patterns_parser_test.dart @@ -61,7 +61,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -90,7 +90,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -122,7 +122,7 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -152,7 +152,7 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -215,7 +215,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -240,7 +240,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -268,7 +268,7 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -319,7 +319,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -353,7 +353,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -390,7 +390,7 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -459,7 +459,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -489,7 +489,7 @@ void f(x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -522,7 +522,7 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -3243,7 +3243,7 @@ f(x, y) => [if (x case _ when y + () => 0) 0]; IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case @@ -3281,7 +3281,7 @@ f(x, y) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x caseClause: CaseClause caseKeyword: case diff --git a/pkg/analyzer/test/generated/recovery_parser_test.dart b/pkg/analyzer/test/generated/recovery_parser_test.dart index 7ae5b52a700..265cca0aaf3 100644 --- a/pkg/analyzer/test/generated/recovery_parser_test.dart +++ b/pkg/analyzer/test/generated/recovery_parser_test.dart @@ -1077,7 +1077,7 @@ class C { MethodDeclaration method = declaration.members[0] as MethodDeclaration; BlockFunctionBody body = method.body as BlockFunctionBody; IfStatement ifStatement = body.block.statements[1] as IfStatement; - IsExpression expression = ifStatement.condition as IsExpression; + IsExpression expression = ifStatement.expression as IsExpression; expect(expression.expression, isNotNull); expect(expression.isOperator, isNotNull); expect(expression.notOperator, isNotNull); diff --git a/pkg/analyzer/test/generated/statement_parser_test.dart b/pkg/analyzer/test/generated/statement_parser_test.dart index 8bc677016a3..fd9a8e6b5c9 100644 --- a/pkg/analyzer/test/generated/statement_parser_test.dart +++ b/pkg/analyzer/test/generated/statement_parser_test.dart @@ -875,7 +875,7 @@ main() { assertNoErrors(); expect(statement.ifKeyword, isNotNull); expect(statement.leftParenthesis, isNotNull); - expect(statement.condition, isNotNull); + expect(statement.expression, isNotNull); expect(statement.rightParenthesis, isNotNull); expect(statement.thenStatement, isNotNull); expect(statement.elseKeyword, isNotNull); @@ -887,7 +887,7 @@ main() { assertNoErrors(); expect(statement.ifKeyword, isNotNull); expect(statement.leftParenthesis, isNotNull); - expect(statement.condition, isNotNull); + expect(statement.expression, isNotNull); expect(statement.rightParenthesis, isNotNull); expect(statement.thenStatement, isNotNull); expect(statement.elseKeyword, isNotNull); @@ -899,7 +899,7 @@ main() { assertNoErrors(); expect(statement.ifKeyword, isNotNull); expect(statement.leftParenthesis, isNotNull); - expect(statement.condition, isNotNull); + expect(statement.expression, isNotNull); expect(statement.rightParenthesis, isNotNull); expect(statement.thenStatement, isNotNull); expect(statement.elseKeyword, isNotNull); @@ -911,7 +911,7 @@ main() { assertNoErrors(); expect(statement.ifKeyword, isNotNull); expect(statement.leftParenthesis, isNotNull); - expect(statement.condition, isNotNull); + expect(statement.expression, isNotNull); expect(statement.rightParenthesis, isNotNull); expect(statement.thenStatement, isNotNull); expect(statement.elseKeyword, isNull); @@ -923,7 +923,7 @@ main() { assertNoErrors(); expect(statement.ifKeyword, isNotNull); expect(statement.leftParenthesis, isNotNull); - expect(statement.condition, isNotNull); + expect(statement.expression, isNotNull); expect(statement.rightParenthesis, isNotNull); expect(statement.thenStatement, isNotNull); expect(statement.elseKeyword, isNull); diff --git a/pkg/analyzer/test/generated/utilities_test.dart b/pkg/analyzer/test/generated/utilities_test.dart index af345be3a42..7feb3dc0fc0 100644 --- a/pkg/analyzer/test/generated/utilities_test.dart +++ b/pkg/analyzer/test/generated/utilities_test.dart @@ -1114,7 +1114,7 @@ void f() { destination: findNode.ifStatement('true'), source: findNode.ifStatement('false'), childAccessors: [ - (node) => node.condition, + (node) => node.expression, (node) => node.thenStatement, (node) => node.elseStatement!, ], 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 c1a4cd24562..3b09e8b5185 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 @@ void f(Object x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object @@ -62,7 +62,7 @@ final y = [ if (x case var a) a ]; IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@getter::x staticType: int @@ -112,7 +112,7 @@ void f(Object x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object @@ -191,7 +191,7 @@ void f(Object x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object @@ -254,7 +254,7 @@ class A { IfElement ifKeyword: if leftParenthesis: ( - condition: SuperExpression + expression: SuperExpression superKeyword: super staticType: A rightParenthesis: ) @@ -284,7 +284,7 @@ class A { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object @@ -326,7 +326,7 @@ void f(bool Function() a) { IfElement ifKeyword: if leftParenthesis: ( - condition: FunctionExpressionInvocation + expression: FunctionExpressionInvocation function: SimpleIdentifier token: a staticElement: self::@function::f::@parameter::a @@ -356,7 +356,7 @@ void f(int Function() a) { IfElement ifKeyword: if leftParenthesis: ( - condition: FunctionExpressionInvocation + expression: FunctionExpressionInvocation function: SimpleIdentifier token: a staticElement: self::@function::f::@parameter::a @@ -394,7 +394,7 @@ void f(Object x, bool Function() a) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object @@ -438,7 +438,7 @@ void f(Object x) { IfElement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object 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 664e2a85a4a..29d9ff97b8c 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 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: dynamic @@ -61,7 +61,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -144,7 +144,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -228,7 +228,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -313,7 +313,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -397,7 +397,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -476,7 +476,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -559,7 +559,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -650,7 +650,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -736,7 +736,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -815,7 +815,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -912,7 +912,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -1006,7 +1006,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -1082,7 +1082,7 @@ void f(Object? x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: Object? @@ -1157,7 +1157,7 @@ class A { IfStatement ifKeyword: if leftParenthesis: ( - condition: SuperExpression + expression: SuperExpression superKeyword: super staticType: A rightParenthesis: ) @@ -1183,7 +1183,7 @@ class A { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: dynamic @@ -1225,7 +1225,7 @@ void f(bool Function() a) { IfStatement ifKeyword: if leftParenthesis: ( - condition: FunctionExpressionInvocation + expression: FunctionExpressionInvocation function: SimpleIdentifier token: a staticElement: self::@function::f::@parameter::a @@ -1255,7 +1255,7 @@ void f(int Function() a) { IfStatement ifKeyword: if leftParenthesis: ( - condition: FunctionExpressionInvocation + expression: FunctionExpressionInvocation function: SimpleIdentifier token: a staticElement: self::@function::f::@parameter::a @@ -1293,7 +1293,7 @@ void f(x, bool Function() a) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: dynamic @@ -1337,7 +1337,7 @@ void f(x) { IfStatement ifKeyword: if leftParenthesis: ( - condition: SimpleIdentifier + expression: SimpleIdentifier token: x staticElement: self::@function::f::@parameter::x staticType: dynamic 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 809df087f47..7f53cb53c03 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 @@ void f(int x) { 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 7f7a5f65ed8..4fde7b3d43b 100644 --- a/pkg/analyzer/test/src/summary/elements_test.dart +++ b/pkg/analyzer/test/src/summary/elements_test.dart @@ -15207,7 +15207,7 @@ library IfElement ifKeyword: if @29 leftParenthesis: ( @32 - condition: BooleanLiteral + expression: BooleanLiteral literal: true @33 staticType: bool rightParenthesis: ) @37 @@ -15251,7 +15251,7 @@ library IfElement ifKeyword: if @29 leftParenthesis: ( @32 - condition: BooleanLiteral + expression: BooleanLiteral literal: true @33 staticType: bool rightParenthesis: ) @37 @@ -15443,7 +15443,7 @@ library IfElement ifKeyword: if @34 leftParenthesis: ( @37 - condition: BooleanLiteral + expression: BooleanLiteral literal: true @38 staticType: bool rightParenthesis: ) @42 @@ -17259,7 +17259,7 @@ library IfElement ifKeyword: if @29 leftParenthesis: ( @32 - condition: BooleanLiteral + expression: BooleanLiteral literal: true @33 staticType: bool rightParenthesis: ) @37 diff --git a/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart b/pkg/analyzer_plugin/lib/src/utilities/completion/optype.dart index 4303bc3e734..080af053a23 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 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor { @override void visitIfElement(IfElement node) { - if (identical(entity, node.condition)) { + if (identical(entity, node.expression)) { optype.completionLocation = 'IfElement_condition'; optype.includeReturnValueSuggestions = true; optype.includeTypeNameSuggestions = true; @@ -949,7 +949,7 @@ class _OpTypeAstVisitor extends GeneralizingAstVisitor { 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 26d125601c5..2b0c9c6dca3 100644 --- a/pkg/nnbd_migration/lib/src/edge_builder.dart +++ b/pkg/nnbd_migration/lib/src/edge_builder.dart @@ -1117,11 +1117,11 @@ class EdgeBuilder extends GeneralizingAstVisitor @override DecoratedType? visitIfElement(IfElement node) { _flowAnalysis!.ifStatement_conditionBegin(); - _checkExpressionNotNull(node.condition); - _flowAnalysis!.ifStatement_thenBegin(node.condition, node); + _checkExpressionNotNull(node.expression); + _flowAnalysis!.ifStatement_thenBegin(node.expression, node); NullabilityNode? trueGuard; NullabilityNode? falseGuard; - if (identical(_conditionInfo?.condition, node.condition)) { + if (identical(_conditionInfo?.condition, node.expression)) { trueGuard = _conditionInfo!.trueGuard; falseGuard = _conditionInfo!.falseGuard; _variables.recordConditionalDiscard(source, node, @@ -1159,10 +1159,10 @@ class EdgeBuilder extends GeneralizingAstVisitor @override DecoratedType? visitIfStatement(IfStatement node) { _flowAnalysis!.ifStatement_conditionBegin(); - _checkExpressionNotNull(node.condition); + _checkExpressionNotNull(node.expression); NullabilityNode? trueGuard; NullabilityNode? falseGuard; - if (identical(_conditionInfo?.condition, node.condition)) { + if (identical(_conditionInfo?.condition, node.expression)) { trueGuard = _conditionInfo!.trueGuard; falseGuard = _conditionInfo!.falseGuard; _variables.recordConditionalDiscard(source, node, @@ -1172,7 +1172,7 @@ class EdgeBuilder extends GeneralizingAstVisitor _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 8a071dd0c5e..31609d64933 100644 --- a/pkg/nnbd_migration/lib/src/fix_aggregator.dart +++ b/pkg/nnbd_migration/lib/src/fix_aggregator.dart @@ -889,8 +889,8 @@ class NodeChangeForIfElement extends NodeChange @override EditPlan _apply(IfElement node, FixAggregator aggregator) { - return _applyConditional(node, aggregator, node.condition, node.thenElement, - node.elseElement) ?? + return _applyConditional(node, aggregator, node.expression, + node.thenElement, node.elseElement) ?? aggregator.innerPlanForNode(node); } } @@ -903,7 +903,7 @@ class NodeChangeForIfStatement extends NodeChange @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 d2902c27953..b514114769d 100644 --- a/pkg/scrape/example/null_aware.dart +++ b/pkg/scrape/example/null_aware.dart @@ -272,7 +272,7 @@ class NullVisitor extends ScrapeVisitor { } String? context; - if (parent is IfStatement && node == parent.condition) { + if (parent is IfStatement && node == parent.expression) { context = 'if'; } else if (parent is BinaryExpression && parent.operator.type == TokenType.AMPERSAND_AMPERSAND) {