Skip to content

Commit

Permalink
docs: Add more info about how to discover main class to run
Browse files Browse the repository at this point in the history
  • Loading branch information
tgodzik committed Feb 14, 2023
1 parent 966d799 commit 2884775
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 4 deletions.
29 changes: 26 additions & 3 deletions docs/integrations/debug-adapter-protocol.md
Expand Up @@ -33,8 +33,8 @@ command.
Starting a Debug Adapter Protocol session might take some time, since it needs
to set up all the neccesary utilities for debugging. Metals also provides a
`shellCommand` field, which will be present in the command attached to the run
main methods code lenses. This field can be used to simply run the process quickly
without the debugging capabilities.
main methods code lenses. This field can be used to simply run the process
quickly without the debugging capabilities.

If you can't or won't support DAP, you can use the `runProvider` instead of
`debugProvider `option in the initialization options sent from the editor to the
Expand Down Expand Up @@ -118,11 +118,34 @@ keys that can be sent as well with the same format as above.

```json
{
"path": "file:///path/to/my/file.scala"
"path": "file:///path/to/my/file.scala",
"runType": "testTarget"
}
```

Instead of `debug-adapter-start` if you only want to get data about the command
to run you can use `discover-jvm-run-command`, which takes the same json as
above, but instead of starting the DAP session it will return the
`DebugSessionParams` object containing targets that this main class can be run
for along with the data about the main class which will take form of:

```json
{
"targets": ["id1"],
"dataKind": "scala-main-class",
"data": {
"class": "Foo",
"arguments": [],
"jvmOptions": [],
"environmentVariables": [],
"shellCommand": "java ..."
}
}
```

where `shellCommand` will be the exact command to run if you want to run it on
your own without DAP.

### Wiring it all together

No matter which method you use, you still need to connect the debug adapter
Expand Down
Expand Up @@ -132,6 +132,21 @@ object ServerCommands {
| "runType": "run"
|}
|```
|
|Response:
|```json
|{
| "targets": ["id1"],
| "dataKind": "scala-main-class",
| "data": {
| "class": "Foo",
| "arguments": [],
| "jvmOptions": [],
| "environmentVariables": [],
| "shellCommand": "java ..."
| }
|}
|```
|""".stripMargin,
)

Expand Down
Expand Up @@ -41,6 +41,7 @@ import scala.meta.internal.metals.ScalaTestSuitesDebugRequest
import scala.meta.internal.metals.SourceMapper
import scala.meta.internal.metals.StacktraceAnalyzer
import scala.meta.internal.metals.StatusBar
import scala.meta.internal.metals.UserConfiguration
import scala.meta.internal.metals.clients.language.MetalsLanguageClient
import scala.meta.internal.metals.clients.language.MetalsQuickPickItem
import scala.meta.internal.metals.clients.language.MetalsQuickPickParams
Expand All @@ -64,7 +65,6 @@ import com.google.common.net.InetAddresses
import com.google.gson.JsonElement
import org.eclipse.lsp4j.MessageParams
import org.eclipse.lsp4j.MessageType
import scala.meta.internal.metals.UserConfiguration

/**
* @param supportsTestSelection test selection hasn't been defined in BSP spec yet.
Expand Down

0 comments on commit 2884775

Please sign in to comment.