Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const displayValue = formatPropertyValue(property);
let variablesReference: number;
if (property.hasChildren || property.type === 'array' || property.type === 'object') {
// if the property has children, we have to send a variableReference back to VS Code
// so it can receive the child elements in another request.
// for arrays and objects we do it even when it does not have children so the user can still expand/collapse the entry
variablesReference = this._variableIdCounter++;
if (property instanceof xdebug.Property) {
this._properties.set(variablesReference, property);
} else if (property instanceof xdebug.EvalResultProperty) {
this._evalResultProperties.set(variablesReference, property);
}
} else {
variablesReference = 0;
}
return new vscode.Variable(property.name, displayValue, variablesReference);
})
}
threadId = 0;
}
const variables = new Array();
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);
}
if(line.startsWith("END"))
{
this.varResp[id].body = {
variables: vars
};
this.sendResponse(this.varResp[id]);
this.processLine = undefined;
return;
}
var infos = line.split(":");
line = infos[0]+":"+infos[1]+":"+infos[2]+":"+infos[3];
if(infos.length>7)
{ //the value can contains : , we need to rejoin it.
infos[6] = infos.splice(6).join(":");
}
var v = new debugadapter.Variable(infos[4],infos[6],line);
v = this.getVariableFormat(v,infos[5],infos[6],"value",line,id);
vars.push(v);
}
}
let createVariable = (name: string, value: any): Variable => {
let text = repr(value);
let numIndexed;
let numNamed;
switch (value.kind) {
case 'plain':
return new Variable(name, text);
case 'con':
numNamed = 0;
numIndexed = 1;
break;
case 'record':
case 'tuple':
numNamed = value.items.length;
numIndexed = 0;
break;
case 'list':
case 'array':
numIndexed = value.items.length;
numNamed = 0;
break;
}
numNamed = 0;
numIndexed = 1;
break;
case 'record':
case 'tuple':
numNamed = value.items.length;
numIndexed = 0;
break;
case 'list':
case 'array':
numIndexed = value.items.length;
numNamed = 0;
break;
}
return new Variable(name, text,
this._variableHandles.create(new Expander(expander(value))),
numIndexed, numNamed
);
};
vs = this.frameVariableScopes[frameId];
} else if (scopeType === "global") {
vs = this.frameVariableGlobalScopes[frameId];
}
if (vs) {
for (const [name, val] of Object.entries(vs)) {
let valString: string;
try {
valString = JSON.stringify(val);
} catch (e) {
valString = String(val);
}
variables.push(new Variable(name, valString));
}
}
response.body = {
variables,
};
this.sendResponse(response);
}