本文整理匯總了TypeScript中vscode-debugadapter-testsupport.DebugClient.variablesRequest方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript DebugClient.variablesRequest方法的具體用法?TypeScript DebugClient.variablesRequest怎麽用?TypeScript DebugClient.variablesRequest使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vscode-debugadapter-testsupport.DebugClient
的用法示例。
在下文中一共展示了DebugClient.variablesRequest方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should add a condition to an already set breakpoint', async function() {
await util.receivePageLoadedEvent(dc);
let sourcePath = path.join(TESTDATA_PATH, 'web/main.js');
await util.setBreakpoints(dc, sourcePath, [ { line: 24 } ]);
let stoppedEvent = await util.runCommandAndReceiveStoppedEvent(dc,
() => util.evaluate(dc, 'factorial(5)')
);
let threadId = stoppedEvent.body.threadId!;
let stackTrace = await dc.stackTraceRequest({ threadId });
let scopes = await dc.scopesRequest({ frameId: stackTrace.body.stackFrames[0].id });
let variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[0].variablesReference });
let variables = variablesResponse.body.variables;
assert.equal(util.findVariable(variables, 'n').value, '5');
await util.setBreakpoints(dc, sourcePath, [ { line: 24, condition: 'n === 2' } ]);
await dc.continueRequest({ threadId });
await util.runCommandAndReceiveStoppedEvent(dc,
() => util.evaluate(dc, 'factorial(5)')
);
stackTrace = await dc.stackTraceRequest({ threadId });
scopes = await dc.scopesRequest({ frameId: stackTrace.body.stackFrames[0].id });
variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[0].variablesReference });
variables = variablesResponse.body.variables;
assert.equal(util.findVariable(variables, 'n').value, '2');
});
示例2: startAndGetProperties
async function startAndGetProperties(dc: DebugClient, bpLine: number, trigger: string): Promise<DebugProtocol.Variable[]> {
await util.setBreakpoints(dc, SOURCE_PATH, [ bpLine ]);
util.evaluate(dc, trigger);
let stoppedEvent = await util.receiveStoppedEvent(dc);
let stackTrace = await dc.stackTraceRequest({ threadId: stoppedEvent.body.threadId! });
let scopes = await dc.scopesRequest({ frameId: stackTrace.body.stackFrames[0].id });
let variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[0].variablesReference });
let variable = util.findVariable(variablesResponse.body.variables, 'x');
let propertiesResponse = await dc.variablesRequest({ variablesReference: variable.variablesReference });
return propertiesResponse.body.variables;
}
示例3: it
it('should show and execute getters lifted from prototypes', async function() {
dc = await util.initDebugClient(TESTDATA_PATH, true, { liftAccessorsFromPrototypes: 2 });
let properties1 = await startAndGetProperties(dc, 116, 'protoGetter()');
let getterProperty1 = util.findVariable(properties1, 'y');
let getterPropertyResponse1 = await dc.variablesRequest({ variablesReference: getterProperty1.variablesReference });
let getterValue1 = util.findVariable(getterPropertyResponse1.body.variables, 'Value from Getter').value;
assert.equal(getterValue1, '"foo"');
let getterProperty2 = util.findVariable(properties1, 'z');
let getterPropertyResponse2 = await dc.variablesRequest({ variablesReference: getterProperty2.variablesReference });
let getterValue2 = util.findVariable(getterPropertyResponse2.body.variables, 'Value from Getter').value;
assert.equal(getterValue2, '"bar"');
});
示例4: assert
dc.waitForEvent('stopped').then(async (response1) => {
let response2 = await dc.stackTraceRequest({ threadId: response1.body.threadId, startFrame: 20, levels: 10 });
assert(response2.body.stackFrames.length == 10)
let response3 = await dc.scopesRequest({ frameId: response2.body.stackFrames[0].id });
let response4 = await dc.variablesRequest({ variablesReference: response3.body.scopes[0].variablesReference });
assert(response4.body.variables[0].name == 'levelsToGo');
assert(response4.body.variables[0].value == '20');
}),
示例5: it
it('should report keys with spaces correctly', async () => {
const arrayWithSpaceKey = localVariables.find(variable => variable.name === '$arrayWithSpaceKey');
assert.isDefined(arrayWithSpaceKey);
assert.propertyVal(arrayWithSpaceKey, 'value', 'array(1)');
assert.property(arrayWithSpaceKey, 'variablesReference');
const arrayWithSpaceKeyItems = (await client.variablesRequest({variablesReference: arrayWithSpaceKey.variablesReference})).body.variables;
assert.lengthOf(arrayWithSpaceKeyItems, 1);
assert.propertyVal(arrayWithSpaceKeyItems[0], 'name', 'space key');
assert.propertyVal(arrayWithSpaceKeyItems[0], 'value', '1');
});
示例6: it
it('should inspect watches evaluated while running', async function() {
let sourcePath = path.join(TESTDATA_PATH, 'web/main.js');
await util.setBreakpoints(dc, sourcePath, [ 25 ]);
let evalResult = await dc.evaluateRequest({ expression: 'obj', context: 'watch' });
let inspectResult = await dc.variablesRequest({
variablesReference: evalResult.body.variablesReference
});
assert.equal(util.findVariable(inspectResult.body.variables, 'x').value, '17');
});
示例7: it
it('should inspect variables of different types in different scopes', async function() {
let sourcePath = path.join(TESTDATA_PATH, 'web/main.js');
await util.setBreakpoints(dc, sourcePath, [ 19 ]);
util.evaluate(dc, 'vars({ key: "value" })');
let stoppedEvent = await util.receiveStoppedEvent(dc);
let stackTrace = await dc.stackTraceRequest({ threadId: stoppedEvent.body.threadId! });
let scopes = await dc.scopesRequest({ frameId: stackTrace.body.stackFrames[0].id });
let variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[0].variablesReference });
let variables = variablesResponse.body.variables;
assert.equal(util.findVariable(variables, 'str2').value, '"foo"');
assert.equal(util.findVariable(variables, 'undef').value, 'undefined');
assert.equal(util.findVariable(variables, 'nul').value, 'null');
assert.equal(util.findVariable(variables, 'sym1').value, 'Symbol(Local Symbol)');
assert.equal(util.findVariable(variables, 'sym2').value, 'Symbol(Global Symbol)');
assert.equal(util.findVariable(variables, 'sym3').value, 'Symbol(Symbol.iterator)');
variablesResponse = await dc.variablesRequest({
variablesReference: util.findVariable(variables, 'this').variablesReference
});
variables = variablesResponse.body.variables;
assert.equal(util.findVariable(variables, 'scrollX').value, '0');
variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[1].variablesReference });
variables = variablesResponse.body.variables;
assert.equal(util.findVariable(variables, 'bool1').value, 'false');
assert.equal(util.findVariable(variables, 'bool2').value, 'true');
assert.equal(util.findVariable(variables, 'num1').value, '0');
assert.equal(util.findVariable(variables, 'num2').value, '120');
assert.equal(util.findVariable(variables, 'str1').value, '""');
variablesResponse = await dc.variablesRequest({ variablesReference: scopes.body.scopes[2].variablesReference });
let variable = util.findVariable(variablesResponse.body.variables, 'arg')!;
assert.equal(variable.value, '{key: "value"}');
variablesResponse = await dc.variablesRequest({ variablesReference: variable.variablesReference });
assert.equal(util.findVariable(variablesResponse.body.variables, 'key').value, '"value"');
assert.equal(util.findVariable(variablesResponse.body.variables, 'Symbol(Local Symbol)').value, '"Symbol-keyed property 1"');
assert.equal(util.findVariable(variablesResponse.body.variables, 'Symbol(Symbol.iterator)').value, '"Symbol-keyed property 2"');
});