-
Notifications
You must be signed in to change notification settings - Fork 439
Add infrastructure for automated validation of syntax node structure #1748
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
Add infrastructure for automated validation of syntax node structure #1748
Conversation
@swift-ci Please test |
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.
This is looking good.
Maybe when it's merged we could add issues for the failures we want to be fixed as they are good first issues for newcomers who want to join the community 🙌
f613daf
to
a09e768
Compare
@swift-ci Please test |
@swift-ci Please test Windows |
a09e768
to
b0d3092
Compare
The goal here is to generalize the API inconsistency reported by @AnthonyLatsis and automatically detect them. There are valid reasons for nodes or children to violate these base rules. My idea is that we note these exceptions in expected failures, ideally with a sort explanation that motivates the deviation from standard naming rules. We aren’t running these tests at the moment yet. I’d like to merge them as a starting point for API improvement ideas at the moment. The current rules are - All nodes with base kind e.g. `ExprSyntax` should end with `ExprSyntax`. - If a child has a single keyword as its choice, it should be named `*Keyword` (e.g. `ImportKeyword`) - If a child has a single non-keyword token kind, name it the same as the the token choice (e.g. `LeftParen`) - If a token only has keyword token choices, its name should end with `Keyword`. - Children that have the same type also have the same child name. - Every node that can conform to a trait does so
b0d3092
to
02a0c5d
Compare
@swift-ci Please test |
Nice, I'd say the rules generally make sense. And we can always have expected failures for when we really want to differ for some reason. Thanks Alex! |
The goal here is to generalize the API inconsistency reported by @AnthonyLatsis and automatically detect them.
There are valid reasons for nodes or children to violate these base rules. My idea is that we note these exceptions in expected failures, ideally with a sort explanation that motivates the deviation from standard naming rules.
We aren’t running these tests at the moment yet. I’d like to merge them as a starting point for API improvement ideas at the moment.
The current rules are
ExprSyntax
should end withExprSyntax
.*Keyword
(e.g.ImportKeyword
) Inconsistent name ofImportDeclSyntax
introducer keyword #1723LeftParen
)Keyword
PrecedenceGroupRelationSyntax.higherThanOrLowerThan
should be namedhigherThanOrLowerThanKeyword
#1747FunctionTypeSyntax.arguments
should be namedparameters
#1720, Inconsistent naming scheme for the elements of tuple-like syntax nodes #1713