in src/debug-adapter/client.ts [344:396]
protected async variablesRequest(
response: DebugProtocol.VariablesResponse,
args: DebugProtocol.VariablesArguments,
) {
let bazelValues: skylark_debugging.IValue[];
let threadId: number;
const reference = args.variablesReference;
const scopeOrParentValue = this.variableHandles.get(reference);
if (scopeOrParentValue instanceof skylark_debugging.Scope) {
// If the reference is to a scope, then we ask for the thread ID
// associated with the scope so that we can associate it later with the
// top-level values in the scope.
threadId = this.scopeThreadIds.get(reference);
bazelValues = (scopeOrParentValue as skylark_debugging.IScope).binding;
} else if (scopeOrParentValue instanceof skylark_debugging.Value) {
// If the reference is to a value, we need to send a request to Bazel to
// get its child values.
threadId = this.valueThreadIds.get(reference);
bazelValues = (await this.bazelConnection.sendRequest({
getChildren: skylark_debugging.GetChildrenRequest.create({
threadId,
valueId: (scopeOrParentValue as skylark_debugging.IValue).id,
}),
})).getChildren.children;
} else {
bazelValues = [];
threadId = 0;
}
const variables = new Array<Variable>();
for (const value of bazelValues) {
let valueHandle: number;
if (value.hasChildren && value.id) {
// Record the value in a handle so that its children can be queried when
// the user expands it in the UI. We also record the thread ID for the
// value since we need it when we make that request later.
valueHandle = this.variableHandles.create(value);
this.valueThreadIds.set(valueHandle, threadId);
} else {
valueHandle = 0;
}
const variable = new Variable(
value.label,
value.description,
valueHandle,
);
variables.push(variable);
}
response.body = { variables };
this.sendResponse(response);
}