Provides code lenses to run tests
sourcekit-lsp should provide code lenses for discovered test methods in a file so that you can run that test case using an action that’s shown inline in the editor, similar to https://rust-analyzer.github.io/manual.html#run.
Tracked in Apple’s issue tracker as rdar://113571236
This would be useful for the @main tag as well. VS Code doesn't need the code lens for the individual tests as run/build buttons are already added by the TestExplorer. Maybe other editors will though, so we'd need some way of indicating which code lens we support.
VSCode swift v1.5 has swift.run and swift.debug commands. These could be used by the code lens.
Can I rename this to provide code lens to run main?
Yes, that sounds good to me. Does the Swift Extension report which commands it supports? I couldn’t find anything in the client capabilities.
The LSP spec says
The recommended way to handle commands is to implement their execution on the server side if the client and server provides the corresponding capabilities.
Which I find very confusing. Do you have more context about how command negotiation between client and server is supposed to work?
I'll have to look it up again but I did see somewhere an extension reporting which codelens it supported.
I can send you initialisation options quite easily eg
Params: {
...
"initializationOptions": {
"codeLens": {
"run": { "command": "run" },
"debug": { "command": "debug" }
}
},
"trace": "verbose",
"workspaceFolders": [
{
"uri": "file:///Users/adamfowler/Developer/server/hummingbird-project/hummingbird",
"name": "hummingbird"
}
]
}
InitializationOptions sound good. Do you happen to know if other languages are doing the same? If not, that’s fine.
InitializationOptions sound good. Do you happen to know if other languages are doing the same? If not, that’s fine.
Not sure how the rust extension does it, but the java extension passes quite a lot of custom initialisation data at startup. https://github.com/redhat-developer/vscode-java/blob/7f89debd1508fb82511baf0f977ae1e27c0aa0c4/src/extension.ts#L180
Is this desired anymore? With the testing API, vscode now shows the play button next to each test and suite in the gutter.
This is badly named. It is for adding debug and run code lens to @main. I couldn't rename the issue as I don't own it.
The main consideration I wanted to put into this issue was for editors that aren’t VS Code and thus don’t have the test explorer. Until we’ve investigate that, I’d prefer to keep the issue open.
Ok we should split off a separate task for adding the run/debug code lens