Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Add support for setting variables (#2076)
Browse files Browse the repository at this point in the history
* Add support for setting variables

Fixes #1129

* Propagate the error message
  • Loading branch information
brycekahle authored and ramya-rao-a committed Nov 11, 2018
1 parent 9faffe6 commit 2dfe6ac
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ class GoDebugSession extends DebugSession {
verbose('InitializeRequest');
// This debug adapter implements the configurationDoneRequest.
response.body.supportsConfigurationDoneRequest = true;
response.body.supportsSetVariable = true;
this.sendResponse(response);
verbose('InitializeResponse');
}
Expand Down Expand Up @@ -1157,6 +1158,28 @@ class GoDebugSession extends DebugSession {
});
}

protected setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): void {
verbose('SetVariableRequest');
const scope = {
goroutineID: this.debugState.currentGoroutine.id
};
const setSymbolArgs = {
Scope: scope,
Symbol: args.name,
Value: args.value
};
this.delve.call(this.delve.isApiV1 ? 'SetSymbol' : 'Set', [setSymbolArgs], (err) => {
if (err) {
const errMessage = `Failed to set variable: ${err.toString()}`;
logError(errMessage);
return this.sendErrorResponse(response, 2010, errMessage);
}
response.body = { value: args.value };
this.sendResponse(response);
verbose('SetVariableResponse');
});
}

private addFullyQualifiedName(variables: DebugVariable[]) {
variables.forEach(local => {
local.fullyQualifiedName = local.name;
Expand Down

0 comments on commit 2dfe6ac

Please sign in to comment.