sourcekit-lsp icon indicating copy to clipboard operation
sourcekit-lsp copied to clipboard

Allow macro expansions to be viewed through `GetReferenceDocumentRequest` instead of storing in temporary files

Open lokesh-tr opened this issue 1 year ago • 3 comments

This PR eliminates the storage of temporary macro expansion files for PeekDocumentsRequest by introducing a new LSP Extension GetReferenceDocumentRequest.

The implementation is made in such a way that the URI passed for macro expansions through PeekDocumentsRequest is customised with a new scheme, and expects the client to resolve the contents of this new URI by making a GetReferenceDocumentRequest.

Custom Scheme for Macro Expansions:
`sourcekit-lsp://macro-expansion/LaCb-LcCd.swift?sourceFileURL=&fromLine=&fromColumn=&toLine=&toColumn=&bufferName=`

References:

Previous PR which implemented PeekDocumentsRequest: https://github.com/swiftlang/sourcekit-lsp/pull/1479 Accompanying PR in vscode-swift repository: https://github.com/swiftlang/vscode-swift/pull/971


Expansion of Swift Macros in Visual Studio Code - Google Summer Of Code 2024 @lokesh-tr @ahoppen @adam-fowler

lokesh-tr avatar Jul 17 '24 14:07 lokesh-tr

@ahoppen I have updated the PR and fixed the rebase issue with package specifiers. Ready for full review now. 👍🏻

lokesh-tr avatar Jul 25 '24 15:07 lokesh-tr

@ahoppen ready for review

lokesh-tr avatar Jul 26 '24 10:07 lokesh-tr

@ahoppen Ready for review.

lokesh-tr avatar Jul 29 '24 13:07 lokesh-tr

@ahoppen Fixed everything as you suggested 🙂

lokesh-tr avatar Jul 31 '24 13:07 lokesh-tr

@swift-ci Please test

ahoppen avatar Jul 31 '24 13:07 ahoppen

@swift-ci Please test Windows

ahoppen avatar Jul 31 '24 17:07 ahoppen