Skip to content

Conversation

@RikkiGibson
Copy link
Member

@RikkiGibson RikkiGibson commented Nov 8, 2024

#75554
Precedes #75821

This PR only extracts local functions and blocks to members, with minimal semantic changes. These members will be reused to implement assignment parsing within the conditional access consequence expression.

@RikkiGibson RikkiGibson requested a review from a team as a code owner November 8, 2024 21:49
@ghost ghost added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Nov 8, 2024
private AssignmentExpressionSyntax ParseAssignmentOperator(SyntaxKind operatorExpressionKind, ExpressionSyntax leftOperand, SyntaxToken operatorToken)
{
Debug.Assert(IsExpectedAssignmentOperator(operatorToken.Kind));
Debug.Assert(GetPrecedence(operatorExpressionKind) == Precedence.Assignment);
Copy link
Member Author

@RikkiGibson RikkiGibson Nov 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of passing newPrecedence down thru here, we know it will always be Precedence.Assignment, so we just use that.

// well as `switch` and `with` clauses.

var (operatorTokenKind, operatorExpressionKind) = getOperatorTokenAndExpressionKind();
var (operatorTokenKind, operatorExpressionKind) = GetOperatorTokenAndExpressionKind();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i would change the names as i recommended. the pr will still be small in that case.

return (SyntaxKind.None, SyntaxKind.None);
}

private SyntaxToken EatOperatorToken(SyntaxKind operatorTokenKind)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

EatExpressionOperatorToken

@RikkiGibson RikkiGibson merged commit e30ffb8 into dotnet:features/null-conditional-assignment Nov 8, 2024
@RikkiGibson RikkiGibson deleted the nca-0 branch November 8, 2024 23:56
return _syntaxFactory.AssignmentExpression(
operatorExpressionKind, leftOperand, operatorToken, rhs);
}
return ParseAssignmentOperator(operatorExpressionKind, leftOperand, operatorToken);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i missed this. we should call this ParseAssignmentExpression.

}
}

private AssignmentExpressionSyntax ParseAssignmentOperator(SyntaxKind operatorExpressionKind, ExpressionSyntax leftOperand, SyntaxToken operatorToken)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rename to ParseAssignmentExpression

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants