Commit Graph

6 Commits

Author SHA1 Message Date
Matthew Bastien
a1a92c91b0 fix CodeLensTests to include command arguments 2025-02-20 11:20:05 -05:00
Matthew Bastien
96d8dd09b6 add target display name to run and debug code lenses 2025-02-20 11:20:05 -05:00
Alex Hoppen
4c8916ac60 Merge SKSwiftPMWorkspace into BuildSystemIntegration
The SwiftPM build system integration was the only one in its own modules. Merge it into the `BuildSystemIntegration` modules next to eg. the compilation database build system.
2024-07-25 09:13:46 -07:00
Paul LeMarquand
960317b6cc Enumerate supported code lens commands 2024-07-21 07:40:17 -04:00
Paul LeMarquand
3e8f413b6b Let client supply code lenses it can run
As part of its initialization options the client can pass a
textDocument/codeLens object that lists the supported commands the
client can handle.

It is in the form of a dictionary where the key is the lens name
recognized by SourceKit-LSP and the value is the command as recognized
by the client.

```
initializationOptions: {
    "textDocument/codeLens": {
        supportedCommands: {
            "swift.run": "clientCommandName_Run",
            "swift.debug": "clientCommandName_Debug",
        }
    }
}
```
2024-07-21 07:37:29 -04:00
Paul LeMarquand
293f638186 Add Run/Debug CodeLens Support
Adds a response to the textDocument/codeLens request that returns two
code lenses on the `@main` attribute of an application.

The LSP documentation breaks out the code lens requests into a
[`Code Lens Request`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#textDocument_codeLens)
and a
[`Code Lens Resolve Request`](https://microsoft.github.io/language-server-protocol/specifications/lsp/3.17/specification/#codeLens_resolve),
stating this is for performance reasons. However, there is no intensive
work we need to do in order to resolve the commands for a CodeLens;
we know them based on context at the time of discovery. For this reason
we return resolved lenses with Commands for code lens requests.

A missing piece is only returning code lenses if the file resides in an
executable product. To my knoledge Libraries and Plugins can't have an
`@main` entrypoint and so it doesn't make sense to provide these code
lenses in those contexts.

Some guidance is required on how to best determine if the textDocument
in the request is within an executable product.

`testCodeLensRequestWithInvalidProduct` asserts that no lenses are
returned with the `@main` attribute is on a file in a `.executable`, and
is currently failing until this is addressed.
2024-07-21 07:37:00 -04:00