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

Add support for setting variables #2076

Merged
merged 2 commits into from
Nov 11, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions src/debugAdapter/goDebug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -546,6 +546,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 @@ -1159,6 +1160,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