Commit Graph

9 Commits

Author SHA1 Message Date
Adam Ward
0f82f33f96 Use utf8 column 2025-11-10 11:14:25 -05:00
Adam Ward
ddcddded67 Support swift.play in textDocument/codelens request
- New `swift.play` CodeLens support that is an experimental feature while [swift play](https://github.com/apple/swift-play-experimental/) is still experimental
- Add #Playground macro visitor to parse the macro expansions
- File must `import Playgrounds` to record the macro expansion
- The `swift-play` binary must exist in the toolchain to
- TextDocumentPlayground will record the id and optionally label to match detail you get from
```
$ swift play --list
Building for debugging...
Found 1 Playground
* Fibonacci/Fibonacci.swift:23 "Fibonacci"
```
- Add LSP extension documentation for designing pending `workspace/playground` request
- Add new parsing test cases
- Update CMake files

Issue: #2339 #2343

Add column to unnamed label

Update Sources/SwiftLanguageService/SwiftCodeLensScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Sources/SwiftLanguageService/SwiftPlaygroundsScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Sources/SwiftLanguageService/SwiftPlaygroundsScanner.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Update Tests/SourceKitLSPTests/CodeLensTests.swift

Co-authored-by: Alex Hoppen <alex@alexhoppen.de>

Address review comments

Fix test failures

Fix more review comments

Update for swift-tools-core
2025-11-07 15:51:17 -05:00
Owen Voorhees
f04b971726 Adopt swift-tools-protocols 2025-10-31 14:11:11 -07:00
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