-
Notifications
You must be signed in to change notification settings - Fork 441
Prevent incorrect node_choices
and ignore token_choices
#1034
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
Conversation
@swift-ci Please test |
% end | ||
% | ||
% if token_choices: | ||
if let tok = syntaxNode.as(TokenSyntax.self) { |
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.
We should be able to have init(_: TokenSyntax)
initializer now. (see line: 66)
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.
Good catch. Thanks
d2c1a1c
to
f3a89c2
Compare
@swift-ci Please test |
% # We don't add 'init(_: TokenSyntax)' because we need to check the | ||
% # token kind. | ||
% if choice.is_token(): | ||
% pass |
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.
Please remove the comment too 🙏
% # We don't add 'init(_: TokenSyntax)' because we need to check the
% # token kind.
f3a89c2
to
ecd2ba9
Compare
@swift-ci Please test |
Moves syntax classifications to a new IDEUtils module. Pulls in swiftlang/swift-syntax#1034
ecd2ba9
to
c34bbb6
Compare
This stops us from using `token_choices` in the `SyntaxChildChoices` initializer and thus means that we no longer need to enforce that only expected `token_choices` exist in the syntax tree.
c34bbb6
to
f7b50bc
Compare
@swift-ci Please test |
Moves syntax classifications to a new IDEUtils module. Pulls in swiftlang/swift-syntax#1034
The python files put structural restrictions on the allowed syntax node kinds for
node_choices
,token_choices
andtext_choices
but we weren’t enforcing them anywhere during creation of raw nodes.With #1010 we are actually making use of these restrictions and are failing if the invariant we impose on ourselves are not upheld, which caused #1025.
After some discussion with @rintaro and @bnbarham we agreed that we should:
node_choices
by introducing the equivalent ofSynaxChildChoices
in theRawSyntax
worldnode_choices
. All tokens should have the samenode_choice
. This way we don’t need to look at token kinds to determine which case of aSyntaxChildEnum
a token belongs totoken_choices
andtext_choices
. Since they weren’t enforced, they were misleading and are not providing any real value.Fixes #1025
Resolves rdar://101589498