Open lokesh-tr opened 2 days ago
This looks great! I tried it out and expanded swift-testing's #expect
macro. Then I ran the test and it behaved exactly the same, as expected.
This fixes #564
This looks great! I tried it out and expanded swift-testing's
#expect
macro. Then I ran the test and it behaved exactly the same, as expected.This fixes #564
Thanks @plemarquand for testing this out. 😄
@adam-fowler
@lokesh-tr this all looks good. Shocking how little code it is on the VSCode side
This is due to the fact that we didn't try to create a custom scheme and handle the fetching of documents through the scheme, etc. Other than that, I had finished the major heavy lifting works in sourcekit-lsp side already.
As Alex said in the call let's not make this macro specific and call it PeekDocument or something similar.
I have just now pushed the code to the PR (https://github.com/swiftlang/sourcekit-lsp/pull/1479) with all the necessary updates as we discussed in the call. Let's see how the review goes.
If we could somehow work out how to display multiple peek views this would be even better.
I wish that's possible. I am still trying to research on this and find a solution, but so far, no clue.
@adam-fowler I guess this PR is now ready for review. I will squash the commits, once we pass the review stage.
This PR utilises the following PR in sourcekit-lsp: https://github.com/swiftlang/sourcekit-lsp/pull/1479 This takes a custom
PeekDocumentsRequest
and opens a peek window to display each given document. In the current state, this request is being used byExpandMacroCommand
in sourcekit-lsp to display Macro Expansions.To check out this functionality, build the sourcekit-lsp from this PR https://github.com/swiftlang/sourcekit-lsp/pull/1479. Then, configure your "swift.sourcekit-lsp.serverPath" to the built sourcekit-lsp.
Since the macro expansions feature is behind an experimental feature flag, configure your "swift.sourcekit-lsp.experimentalFeatures" as follows:
The "Expand Macro" will be available as a Code Action when the cursor sits on a Macro annotation, and selecting the code action will trigger the
ExpandMacroCommand
->PeekDocumentsRequest
, and thus shows the Macro Expansions inside a "peeked" editor.Fixes https://github.com/swiftlang/vscode-swift/issues/564
Expansion of Swift Macros in Visual Studio Code - Google Summer Of Code 2024 @lokesh-tr @ahoppen @adam-fowler