Skip to content

Commit

Permalink
docs: add doc for DAP evaluation/completion/setValue features
Browse files Browse the repository at this point in the history
Signed-off-by: azerr <[email protected]>
  • Loading branch information
angelozerr committed Jan 23, 2025
1 parent cf51cce commit c91858f
Show file tree
Hide file tree
Showing 7 changed files with 58 additions and 3 deletions.
35 changes: 32 additions & 3 deletions docs/dap/DAP.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,38 @@ To configure debugging with DAP, you need to fill in:

![DAP Configuration Type/Server](./images/DAP_config_type_server.png)

## Evaluate expression

Evaluate expression is available by consuming the [Evaluate request](https://microsoft.github.io/debug-adapter-protocol//specification.html#Requests_Evaluate)

![Evaluate expression](./images/DAP_debugging_evaluate.png)

### Completion

If debug adapter [supports the `completions` request](https://microsoft.github.io/debug-adapter-protocol//specification.html#Types_Capabilities),
completion should be available in the expression editor by consuming the
[Completion request](https://microsoft.github.io/debug-adapter-protocol//specification.html#Requests_Completions):

![Completion](images/DAP_debugging_completion.png)

## Set value

If debug adapter [supports setting a variable to a value](https://microsoft.github.io/debug-adapter-protocol//specification.html#Types_Capabilities),
the `Set Value...` contextual menu should be available:

![Set Value/Menu](images/DAP_debugging_setValue_menu.png)

You should edit the variable:

![Set Value/Edit](images/DAP_debugging_setValue_edit.png)

the edit apply will consume the
[SetVariable request](https://microsoft.github.io/debug-adapter-protocol//specification.html#Requests_SetVariable):

## Templates

- [Go Delv DAP server](./user-defined-dap/go-delve.md)
- [Swift DAP Server](./user-defined-dap/swift-lldb.md)
- [VSCode JS Debug DAP Server](./user-defined-dap/vscode-js-debug.md)
LSP4IJ provides DAP templates that allow to initialize a given DAP server very quickly:

- [Go Delve DAP server](./user-defined-dap/go-delve.md) which allows you to debug `Go` files.
- [Swift DAP Server](./user-defined-dap/swift-lldb.md) which allows you to debug `Swift` files.
- [VSCode JS Debug DAP Server](./user-defined-dap/vscode-js-debug.md) which allows you to debug `JavaScript/TypeScript` files.
Binary file added docs/dap/images/DAP_debugging_completion.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dap/images/DAP_debugging_evaluate.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dap/images/DAP_debugging_setValue_edit.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/dap/images/DAP_debugging_setValue_menu.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
22 changes: 22 additions & 0 deletions src/main/java/com/redhat/devtools/lsp4ij/dap/client/DAPClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -469,14 +469,36 @@ public CompletableFuture<SetVariableResponse> setVariable(String name,
// Capabilities


/**
* Returns true if the debug adapter supports the 'terminate' request and false otherwise.
*
* @return true if the debug adapter supports the 'terminate' request and false otherwise.
*/
public boolean isSupportsTerminateRequest() {
var capabilities = getCapabilities();
return capabilities != null && Boolean.TRUE.equals(capabilities.getSupportsTerminateRequest());
}

/**
* Returns true if the debug adapter supports the 'completions' request and false otherwise.
*
* @return true if the debug adapter supports the 'completions' request and false otherwise.
*/
public boolean isSupportsCompletionsRequest() {
var capabilities = getCapabilities();
return capabilities != null && Boolean.TRUE.equals(capabilities.getSupportsCompletionsRequest());
}

/**
* Returns true if the debug adapter supports setting a variable to a value and false otherwise.
*
* @return true if the debug adapter supports setting a variable to a value and false otherwise.
*/
public boolean isSupportsSetVariable() {
var capabilities = getCapabilities();
return capabilities != null && Boolean.TRUE.equals(capabilities.getSupportsSetVariable());
}

@NotNull
public DebugAdapterDescriptor getServerDescriptor() {
return debugProcess.getServerDescriptor();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,10 @@ public void computeChildren(@NotNull XCompositeNode node) {
@Nullable
@Override
public XValueModifier getModifier() {
if (!client.isSupportsSetVariable()) {
// The DAP server doesn't support the setting variable, Disable the 'Set Value...' menu.
return null;
}
return new DAPValueModifier(this);
}

Expand Down

0 comments on commit c91858f

Please sign in to comment.