Skip to content
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

Record macro fragment captures #11183

Open
Veykril opened this issue Jan 3, 2022 · 0 comments
Open

Record macro fragment captures #11183

Veykril opened this issue Jan 3, 2022 · 0 comments
Labels
A-ide general IDE features A-macro macro expansion C-Architecture Big architectural things which we need to figure up-front (or suggestions for rewrites :0) ) E-unknown It's unclear if the issue is E-hard or E-easy without digging in

Comments

@Veykril
Copy link
Member

Veykril commented Jan 3, 2022

In short we should be able to ask a token in a macro-call tokentree in what way it has been captured, that is the fragment type it got captured as as well as asking for all the tokens that are part of the same capture.

This would allow us to potentially offer more IDE features for declarative macro-call inputs, as an example lets look at our match_ast macro
https://github.com/rust-analyzer/rust-analyzer/blob/1ba9a924d7b161c52e605e157ee16d582e4a8684/crates/syntax/src/lib.rs#L186-L196
Using this macro causes the match arm expressions in the input to lose all inlay hints. This is due to the input being just a bunch of unparsed tokens, but the fragment captures give us enough information to tell what tokens make up a valid expression in the input which should allow us to properly add inlay hints to these.

Completions would also benefit from this information #11059

The token map rewrite might be relevant here #9403

@Veykril Veykril added E-unknown It's unclear if the issue is E-hard or E-easy without digging in C-Architecture Big architectural things which we need to figure up-front (or suggestions for rewrites :0) ) A-macro macro expansion A-ide general IDE features labels Jan 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-ide general IDE features A-macro macro expansion C-Architecture Big architectural things which we need to figure up-front (or suggestions for rewrites :0) ) E-unknown It's unclear if the issue is E-hard or E-easy without digging in
Projects
None yet
Development

No branches or pull requests

1 participant