Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
console.log("GOT VARIABLES");
console.log(result);
var variables = result[0]["vars"];
var frameArgs = variables[0];
var frameLocals = variables[1];
var argScope = frameArgs.map((v: any) : any => {
let val = {name: v["name"], value: v["value"], variablesReference: 0};
return val;
});
var localScope = frameLocals.map((v: any) : any => {
let val = {name: v["name"], value: v["value"], variablesReference: 0};
return val;
});
const scopes = new Array();
scopes.push(new Scope("Local", this._variableHandles.create(localScope), false));
scopes.push(new Scope("Argument", this._variableHandles.create(argScope), false));
// scopes.push(new Scope("Global", this._variableHandles.create("global_" + frameReference), true));
response.body = {
scopes: scopes
};
debug.sendResponse(response);
});
}
protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments): void {
const frameId = args.frameId;
const data = this.threadManager.getStoredData(frameId);
const frame: VMFrame = data.data as VMFrame;
// TODO: class variables? library variables?
const variablesReference = data.thread.storeData(frame);
const scopes: Scope[] = [];
if (data.thread.exceptionReference) {
scopes.push(new Scope("Exception", data.thread.exceptionReference));
}
scopes.push(new Scope("Locals", variablesReference));
response.body = { scopes };
this.sendResponse(response);
}
scopes: contexts.map(context => {
const variableId = this._variableIdCounter++;
// remember that this new variable ID is assigned to a SCOPE (in XDebug "context"), not a variable (in XDebug "property"),
// so when VS Code does a variablesRequest with that ID we do a context_get and not a property_get
this._contexts.set(variableId, context);
// send VS Code the variable ID as identifier
return new vscode.Scope(context.name, variableId);
})
};
},
{
Frame: frame, Expression: 'Description',
Flags: Contracts_2.PythonEvaluationResultFlags.Raw,
StringRepr: this.lastException.Description,
TypeName: 'string', IsExpandable: false, HexRepr: '',
ChildName: '', ExceptionText: '', Length: 0, Process: undefined
}],
evaluateChildren: false
};
scopes.push(new vscode_debugadapter_1.Scope("Exception", this._variableHandles.create(values), false));
this.lastException = undefined;
}
if (Array.isArray(frame.Locals) && frame.Locals.length > 0) {
const values = { variables: frame.Locals };
scopes.push(new vscode_debugadapter_1.Scope("Local", this._variableHandles.create(values), false));
}
if (Array.isArray(frame.Parameters) && frame.Parameters.length > 0) {
const values = { variables: frame.Parameters };
scopes.push(new vscode_debugadapter_1.Scope("Arguments", this._variableHandles.create(values), false));
}
response.body = { scopes };
this.sendResponse(response);
});
}
protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments): void {
const scopes = new Array();
scopes.push(new Scope('Local', parseInt(args.frameId as any), false));
scopes.push(new Scope('Global', GLOBAL_HANDLE_ID, false));
scopes.push(new Scope('Static', STATIC_HANDLES_START + parseInt(args.frameId as any), false));
response.body = {
scopes: scopes
};
this.sendResponse(response);
}
this.variableCommands.push("ERROR_VAR")
this.variableCommands = this.variableCommands.concat(["LOCALS","PUBLICS","PRIVATES", "PRIVATE_CALLEE","STATICS"]);
//TODO: "GLOBALS","EXTERNALS"
this.varResp = [];
this.varResp.length = this.variableCommands.length;
this.variableEvaluations = [];
this.variableEvaluations.length = this.variableCommands.length;
var n=0;
var scopes = [];
if(inError)
{
n=1;
scopes.push(new debugadapter.Scope("Error",1))
}
scopes = scopes.concat([
new debugadapter.Scope("Local",n+1),
new debugadapter.Scope("Public",n+2),
new debugadapter.Scope("Private local",n+3),
new debugadapter.Scope("Private external",n+4),
new debugadapter.Scope("Statics",n+5)
//new debugadapter.Scope("Globals",6),
//new debugadapter.Scope("Externals",7)
])
var response = this.scopeResponse;
response.body = { scopes: scopes };
this.sendResponse(response)
}
},
{
Frame: frame, Expression: 'Description',
Flags: PythonEvaluationResultFlags.Raw,
StringRepr: this.lastException!.Description,
TypeName: 'string', IsExpandable: false, HexRepr: '',
ChildName: '', ExceptionText: '', Length: 0, Process: undefined
}],
evaluateChildren: false
};
scopes.push(new Scope("Exception", this._variableHandles.create(values), false));
this.lastException = undefined;
}
if (Array.isArray(frame.Locals) && frame.Locals.length > 0) {
const values: IDebugVariable = { variables: frame.Locals };
scopes.push(new Scope("Local", this._variableHandles.create(values), false));
}
if (Array.isArray(frame.Parameters) && frame.Parameters.length > 0) {
const values: IDebugVariable = { variables: frame.Parameters };
scopes.push(new Scope("Arguments", this._variableHandles.create(values), false));
}
response.body = { scopes };
this.sendResponse(response);
});
}
Frame: frame, Expression: 'Type',
Flags: Contracts_2.PythonEvaluationResultFlags.Raw,
StringRepr: this.lastException.TypeName,
TypeName: 'string', IsExpandable: false, HexRepr: '',
ChildName: '', ExceptionText: '', Length: 0, Process: undefined
},
{
Frame: frame, Expression: 'Description',
Flags: Contracts_2.PythonEvaluationResultFlags.Raw,
StringRepr: this.lastException.Description,
TypeName: 'string', IsExpandable: false, HexRepr: '',
ChildName: '', ExceptionText: '', Length: 0, Process: undefined
}],
evaluateChildren: false
};
scopes.push(new vscode_debugadapter_1.Scope("Exception", this._variableHandles.create(values), false));
this.lastException = undefined;
}
if (Array.isArray(frame.Locals) && frame.Locals.length > 0) {
const values = { variables: frame.Locals };
scopes.push(new vscode_debugadapter_1.Scope("Local", this._variableHandles.create(values), false));
}
if (Array.isArray(frame.Parameters) && frame.Parameters.length > 0) {
const values = { variables: frame.Parameters };
scopes.push(new vscode_debugadapter_1.Scope("Arguments", this._variableHandles.create(values), false));
}
response.body = { scopes };
this.sendResponse(response);
});
}
protected scopesRequest(response: DebugProtocol.ScopesResponse, args: DebugProtocol.ScopesArguments): void {
const scopes = new Array();
scopes.push(new Scope('Local', parseInt(args.frameId as any), false));
scopes.push(new Scope('Global', GLOBAL_HANDLE_ID, false));
scopes.push(new Scope('Static', STATIC_HANDLES_START + parseInt(args.frameId as any), false));
response.body = {
scopes: scopes
};
this.sendResponse(response);
}
.getVariableHandler()
.create(new ScopeContainer(SCOPE_TYPES.LOCAL, frameInfo.locals)),
false
)
);
scopes.push(
new Scope(
'Static',
this.logContext
.getVariableHandler()
.create(new ScopeContainer(SCOPE_TYPES.STATIC, frameInfo.statics)),
false
)
);
scopes.push(
new Scope(
'Global',
this.logContext
.getVariableHandler()
.create(new ScopeContainer(SCOPE_TYPES.GLOBAL, frameInfo.globals)),
false
)
);
response.body = { scopes };
this.sendResponse(response);
}