-
Notifications
You must be signed in to change notification settings - Fork 305
Show expanded code of freestanding macro expansions in hover #755
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
Comments
Tracked in Apple’s issue tracker as rdar://110516432 |
I think we do have a code action that does this. If you create a new macro template and build it, you can right click on It’s not quite what Xcode does with the code roll. If you know if VSCode has an option to show the expanded source code inline, we should be able to figure something out how to give you the necessary expansion information. |
I haven't looked into how VS Code would display the expanded macros but other extensions have added additions to the source view, so it should be possible. For example the GitHub extension allows you to see PR comments. |
I suspect that that would probably require dedicated support in the Swift VSCode extension. If you figure out how to display those inline text hint, I’m happy to create an LSP request that gives you the text to display. |
AFAICT there’s nothing actionable for SourceKit-LSP here, so I’m closing this issue. Could you file another issue once you’ve got support in the VSCode plugin to display the macro expansion and then we can discuss what kind of SourceKit-LSP request you need? |
What's your thoughts on including the macro expansion in the
|
I don’t think that scales. In a lot of cases the generated code will span over multiple lines and I don’t think that makes for a good hover response. Also, for attached macros, you would want to show where the generated code is being inserted (e.g. in case of a peer macro) and that also doesn’t fit with the design of hover. |
I don't think spanning over multiple lines is a huge issue. The discussion part of a hover comment can cover many lines. Obviously the positioning is a different issue. We might not be given the UI capabilities in VSCode to insert read only text sections into a text document. So this maybe the only option. |
Do you know which other plugins do show read-only code inline and how they do it? Is it only supported for first-party plugins by Microsoft? |
Ah, OK. Thanks for double-checking. Let’s use this issue to track showing the expanded code for freestanding macro expansions. Attached macro expansions are more tricky because I’m still not sure where to display them, so let’s just skip them for now and not let it stop us doing the simple case. |
How is documentation displayed, is that hover? For all but accessor macros, we could use the insertion position to add some context to the provided generated code. That could be a comment or some extra source. For accessor we'd really need the kind included in the response as well, but there's no reason we couldn't add that. |
Xcode has a nice feature where you can expand macros to see the code they generate. It'd be cool if you could do this with VSCode as well. Could we add a CodeAction or something similar to provide the code expansion?
The text was updated successfully, but these errors were encountered: