Skip to content

Implement Token! macro for syntax kinds, a-la syn #1248

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

Closed
matklad opened this issue May 5, 2019 · 5 comments
Closed

Implement Token! macro for syntax kinds, a-la syn #1248

matklad opened this issue May 5, 2019 · 5 comments
Labels
E-medium fun A technically challenging issue with high impact good first issue

Comments

@matklad
Copy link
Member

matklad commented May 5, 2019

Syn has a lovely Token! macro for defining tokens without naming them: Token![,]:

https://docs.rs/syn/0.15.33/syn/macro.Token.html

We should add a similar macro for our SyntaxKind, to make code like this more readable:

https://github.com/rust-analyzer/rust-analyzer/blob/master/crates/ra_ide_api/src/extend_selection.rs#L137-L138

@matklad matklad added E-medium fun A technically challenging issue with high impact good first issue labels May 5, 2019
@matklad
Copy link
Member Author

matklad commented May 5, 2019

Though, I am not sure if macros are allowed in patterns. If they aren't, then probably we should stick with the current approach.

@edwin0cheng
Copy link
Member

edwin0cheng commented May 5, 2019

Macro is allowed in pattern :) See #1220

@pasa
Copy link
Contributor

pasa commented May 8, 2019

I have never created rust macro. I think it is a good day to start.

bors bot added a commit that referenced this issue May 13, 2019
1257: Implemented tkn! macro for syntax kinds r=matklad a=pasa

Implementation of #1248

Co-authored-by: Sergey Parilin <sergey.parilin@fxdd.com>
@pasa
Copy link
Contributor

pasa commented May 15, 2019

Hi. I've made PR with T! macro apply for whole project. I hope it will be helpful.
In addition I figured out that T![(] and T![)] are not working so I've changed them to T!['('] and T![')'].

bors bot added a commit that referenced this issue May 15, 2019
1278: Apply T! macro where posible r=matklad a=pasa

apply T! macro implemented in #1248

Co-authored-by: Sergey Parilin <sergey.parilin@fxdd.com>
@lnicola
Copy link
Member

lnicola commented May 15, 2019

Can this be closed?

@matklad matklad closed this as completed May 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
E-medium fun A technically challenging issue with high impact good first issue
Projects
None yet
Development

No branches or pull requests

4 participants