-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft proposed revision of syntax model for deconstruction declarations #12688
Closed
Closed
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1121,7 +1121,7 @@ | |
</Node> | ||
<Node Name="DeclarationExpressionSyntax" Base="ExpressionSyntax"> | ||
<Kind Name="DeclarationExpression"/> | ||
<Field Name="Declaration" Type="VariableDeclarationSyntax"> | ||
<Field Name="Declaration" Type="MultiVariableDeclarationSyntax"> | ||
<PropertyComment> | ||
<summary>Declaration representing the variable declared in an out parameter.</summary> | ||
</PropertyComment> | ||
|
@@ -1793,6 +1793,7 @@ | |
<Kind Name="SemicolonToken"/> | ||
</Field> | ||
</Node> | ||
|
||
<Node Name="LocalDeclarationStatementSyntax" Base="StatementSyntax"> | ||
<Kind Name="LocalDeclarationStatement"/> | ||
<Field Name="Modifiers" Type="SyntaxList<SyntaxToken>"> | ||
|
@@ -1809,26 +1810,10 @@ | |
</Field> | ||
</Node> | ||
|
||
<Node Name="VariableDeconstructionDeclaratorSyntax" Base="CSharpSyntaxNode" AvoidAutoCreation="true" InternalFactory="true"> | ||
<Kind Name="VariableDeconstructionDeclarator"/> | ||
<Field Name="OpenParenToken" Type="SyntaxToken"> | ||
<Kind Name="OpenParenToken"/> | ||
</Field> | ||
<Field Name="Variables" Type="SeparatedSyntaxList<VariableDeclarationSyntax>"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken"> | ||
<Kind Name="CloseParenToken"/> | ||
</Field> | ||
<Field Name="EqualsToken" Type="SyntaxToken" Optional="true"> | ||
<Kind Name="EqualsToken"/> | ||
</Field> | ||
<Field Name="Value" Type="ExpressionSyntax" Optional="true"/> | ||
</Node> | ||
|
||
<Node Name="VariableDeclarationSyntax" Base="CSharpSyntaxNode" AvoidAutoCreation="true" InternalFactory="true"> | ||
<Node Name="VariableDeclarationSyntax" Base="CSharpSyntaxNode"> | ||
<Kind Name="VariableDeclaration"/> | ||
<Field Name="Type" Type="TypeSyntax" Optional="true"/> | ||
<Field Name="Type" Type="TypeSyntax"/> | ||
<Field Name="Variables" Type="SeparatedSyntaxList<VariableDeclaratorSyntax>"/> | ||
<Field Name="Deconstruction" Type="VariableDeconstructionDeclaratorSyntax" Optional="true"/> | ||
</Node> | ||
|
||
<Node Name="VariableDeclaratorSyntax" Base="CSharpSyntaxNode"> | ||
|
@@ -1852,13 +1837,71 @@ | |
</Field> | ||
<Field Name="Value" Type="ExpressionSyntax"/> | ||
</Node> | ||
|
||
|
||
<AbstractNode Name="MultiVariableDeclarationSyntax" Base="CSharpSyntaxNode"> | ||
</AbstractNode> | ||
<Node Name="SimpleVariableDeclarationSyntax" Base="MultiVariableDeclarationSyntax"> | ||
<Field Name="Type" Type="TypeSyntax"/> | ||
<Field Name="Declarator" Type="MultiVariableDeclaratorSyntax"/> | ||
</Node> | ||
<Node Name="TupleDeconstructionDeclarationSyntax" Base="MultiVariableDeclarationSyntax"> | ||
<Field Name="OpenParenToken" Type="SyntaxToken"> | ||
<Kind Name="OpenParenToken"/> | ||
</Field> | ||
<Field Name="Variables" Type="SeparatedSyntaxList<MultiVariableDeclarationSyntax>"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken"> | ||
<Kind Name="CloseParenToken"/> | ||
</Field> | ||
</Node> | ||
|
||
<AbstractNode Name="MultiVariableDeclaratorSyntax" Base="CSharpSyntaxNode"> | ||
</AbstractNode> | ||
<Node Name="SingleVariableDeclaratorSyntax" Base="MultiVariableDeclaratorSyntax"> | ||
<Field Name="Identifier" Type="SyntaxToken"> | ||
<Kind Name="IdentifierToken"/> | ||
</Field> | ||
</Node> | ||
<Node Name="TupleDeconstructionDeclaratorSyntax" Base="MultiVariableDeclaratorSyntax"> | ||
<Field Name="OpenParenToken" Type="SyntaxToken"> | ||
<Kind Name="OpenParenToken"/> | ||
</Field> | ||
<Field Name="Variables" Type="SeparatedSyntaxList<MultiVariableDeclaratorSyntax>"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken"> | ||
<Kind Name="CloseParenToken"/> | ||
</Field> | ||
</Node> | ||
<Node Name="WildcardVariableDeclaratorSyntax" Base="MultiVariableDeclaratorSyntax"> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'd call this |
||
<Field Name="AsteriskToken" Type="SyntaxToken"> | ||
<Kind Name="AsteriskToken"/> | ||
</Field> | ||
</Node> | ||
<!-- It is possible to add additional subtypes of MultiVariableDeclaratorSyntax | ||
to assist with error recovery. --> | ||
|
||
<Node Name="DeconstructionDeclarationStatementSyntax" Base="StatementSyntax"> | ||
<Field Name="Modifiers" Type="SyntaxList<SyntaxToken>"/> | ||
<Field Name="Assignment" Type="DeconstructionDeclarationAssignment"/> | ||
<Field Name="SemicolonToken" Type="SyntaxToken"> | ||
<Kind Name="SemicolonToken"/> | ||
</Field> | ||
</Node> | ||
<Node Name="DeconstructionDeclarationAssignment" Base="CSharpSyntaxNode"> | ||
<Field Name="Declaration" Type="MultiVariableDeclarationSyntax"/> | ||
<Field Name="EqualsToken" Type="SyntaxToken"> | ||
<Kind Name="EqualsToken"/> | ||
</Field> | ||
<Field Name="Value" Type="ExpressionSyntax"/> | ||
</Node> | ||
|
||
<Node Name="ExpressionStatementSyntax" Base="StatementSyntax"> | ||
<Kind Name="ExpressionStatement"/> | ||
<Field Name="Expression" Type="ExpressionSyntax"/> | ||
<Field Name="SemicolonToken" Type="SyntaxToken"> | ||
<Kind Name="SemicolonToken"/> | ||
</Field> | ||
</Node> | ||
|
||
<Node Name="EmptyStatementSyntax" Base="StatementSyntax"> | ||
<Kind Name="EmptyStatement"/> | ||
<Field Name="SemicolonToken" Type="SyntaxToken"> | ||
|
@@ -2035,6 +2078,7 @@ | |
<Field Name="RefKeyword" Type="SyntaxToken" Optional="true"> | ||
<Kind Name="RefKeyword"/> | ||
</Field> | ||
<Field Name="Deconstuction" Type="DeconstructionDeclarationAssignment" Optional="true"/> | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Deconstruction |
||
<Field Name="Declaration" Type="VariableDeclarationSyntax" Optional="true"/> | ||
<Field Name="Initializers" Type="SeparatedSyntaxList<ExpressionSyntax>"/> | ||
<Field Name="FirstSemicolonToken" Type="SyntaxToken"> | ||
|
@@ -2051,30 +2095,68 @@ | |
<Field Name="Statement" Type="StatementSyntax"/> | ||
</Node> | ||
|
||
<Node Name="ForEachStatementSyntax" Base="StatementSyntax" InternalFactory="true"> | ||
<Kind Name="ForEachStatement"/> | ||
<!-- Because there are two forms of the foreach loop, we make an abstract base. --> | ||
<AbstractNode Name="CommonForEachStatementSyntax" Base="StatementSyntax"> | ||
<Field Name="ForEachKeyword" Type="SyntaxToken"> | ||
<Kind Name="ForEachKeyword"/> | ||
</Field> | ||
<Field Name="OpenParenToken" Type="SyntaxToken"> | ||
<Kind Name="OpenParenToken"/> | ||
</Field> | ||
<Field Name="Type" Type="TypeSyntax" Optional="true"/> | ||
<Field Name="Identifier" Type="SyntaxToken" Optional="true"> | ||
<Field Name="InKeyword" Type="SyntaxToken"> | ||
<Kind Name="InKeyword"/> | ||
</Field> | ||
<Field Name="Expression" Type="ExpressionSyntax"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken"> | ||
<Kind Name="CloseParenToken"/> | ||
</Field> | ||
<Field Name="Statement" Type="StatementSyntax"/> | ||
</AbstractNode> | ||
<Node Name="ForEachStatementSyntax" Base="CommonForEachStatementSyntax"> | ||
<!-- This is the existing C# 6 node. --> | ||
<Kind Name="ForEachStatement"/> | ||
<Field Name="ForEachKeyword" Type="SyntaxToken" Override="true"> | ||
<Kind Name="ForEachKeyword"/> | ||
</Field> | ||
<Field Name="OpenParenToken" Type="SyntaxToken" Override="true"> | ||
<Kind Name="OpenParenToken"/> | ||
</Field> | ||
<Field Name="Type" Type="TypeSyntax"/> | ||
<Field Name="Identifier" Type="SyntaxToken"> | ||
<PropertyComment> | ||
<summary>Gets the identifier.</summary> | ||
</PropertyComment> | ||
<Kind Name="IdentifierToken"/> | ||
</Field> | ||
<Field Name="DeconstructionVariables" Type="VariableDeclarationSyntax" Optional="true"/> | ||
<Field Name="InKeyword" Type="SyntaxToken"> | ||
<Field Name="InKeyword" Type="SyntaxToken" Override="true"> | ||
<Kind Name="InKeyword"/> | ||
</Field> | ||
<Field Name="Expression" Type="ExpressionSyntax"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken"> | ||
<Field Name="Expression" Type="ExpressionSyntax" Override="true"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken" Override="true"> | ||
<Kind Name="CloseParenToken"/> | ||
</Field> | ||
<Field Name="Statement" Type="StatementSyntax"/> | ||
<Field Name="Statement" Type="StatementSyntax" Override="true"/> | ||
</Node> | ||
<!-- We name this "DeclarationForEachStatementSyntax" because it can express existing foreach | ||
loops. We may elect to represent all foreach loops using this node and deprecate (stop parsing | ||
into) the old one. --> | ||
<Node Name="MultiVariableForEachStatementSyntax" Base="CommonForEachStatementSyntax"> | ||
<Kind Name="ForEachStatement"/> | ||
<Field Name="ForEachKeyword" Type="SyntaxToken" Override="true"> | ||
<Kind Name="ForEachKeyword"/> | ||
</Field> | ||
<Field Name="OpenParenToken" Type="SyntaxToken" Override="true"> | ||
<Kind Name="OpenParenToken"/> | ||
</Field> | ||
<Field Name="Declaration" Type="MultiVariableDeclarationSyntax"/> | ||
<Field Name="InKeyword" Type="SyntaxToken" Override="true"> | ||
<Kind Name="InKeyword"/> | ||
</Field> | ||
<Field Name="Expression" Type="ExpressionSyntax" Override="true"/> | ||
<Field Name="CloseParenToken" Type="SyntaxToken" Override="true"> | ||
<Kind Name="CloseParenToken"/> | ||
</Field> | ||
<Field Name="Statement" Type="StatementSyntax" Override="true"/> | ||
</Node> | ||
|
||
<Node Name="UsingStatementSyntax" Base="StatementSyntax"> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From a naming perspective, it seems like perhaps this should just be called BaseVariableDeclarationSyntax.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not a base of
VariableDeclarationSyntax
.In reply to: 71962344 [](ancestors = 71962344)