MCPcopy Create free account
hub / github.com/Snapchat/Valdi / setVariable

Method setVariable

valdi/vscode_debugger/src/adapter/variables.ts:181–202  ·  view source on GitHub ↗
(params: Dap.SetVariableParams)

Source from the content-addressed store, hash-verified

179 }
180
181 async setVariable(params: Dap.SetVariableParams): Promise<Dap.SetVariableResult | Dap.Error> {
182 const object = this._referenceToObject.get(params.variablesReference);
183 if (!object)
184 return errors.createSilentError(localize('error.variableNotFound', 'Variable not found'));
185
186 const expression = params.value;
187 if (!expression)
188 return errors.createUserError(localize('error.emptyExpression', 'Cannot set an empty value'));
189
190 const evaluateResponse = object.scopeRef
191 ? await object.cdp.Debugger.evaluateOnCallFrame({
192 expression,
193 callFrameId: object.scopeRef.callFrameId,
194 })
195 : await object.cdp.Runtime.evaluate({ expression, silent: true });
196 if (!evaluateResponse)
197 return errors.createUserError(localize('error.invalidExpression', 'Invalid expression'));
198 if (evaluateResponse.exceptionDetails)
199 return errorFromException(evaluateResponse.exceptionDetails);
200
201 return this.handleSetVariableEvaluation(params, evaluateResponse, object);
202 }
203
204 private async handleSetVariableEvaluation(
205 params: Dap.SetVariableParams,

Callers

nothing calls this directly

Calls 5

errorFromExceptionFunction · 0.85
evaluateOnCallFrameMethod · 0.80
getMethod · 0.65
evaluateMethod · 0.65

Tested by

no test coverage detected