in src/adapter/daffodilDebug.ts [414:504]
protected async variablesRequest(
response: DebugProtocol.VariablesResponse,
args: DebugProtocol.VariablesArguments,
request?: DebugProtocol.Request
) {
const variables: DebugProtocol.Variable[] = []
if (this._isLongrunning.get(args.variablesReference)) {
// long running
if (request) {
this._cancelationTokens.set(request.seq, false)
}
for (let i = 0; i < 100; i++) {
await timeout(1000)
variables.push({
name: `i_${i}`,
type: 'integer',
value: `${i}`,
variablesReference: 0,
})
if (request && this._cancelationTokens.get(request.seq)) {
break
}
}
if (request) {
this._cancelationTokens.delete(request.seq)
}
} else {
const id = this._variableHandles.get(args.variablesReference)
if (id) {
const i = 12345678
variables.push({
name: id + '_i',
type: 'integer',
value: this._showHex ? '0x' + i.toString(16) : i.toString(10),
__vscodeVariableMenuContext: 'simple',
variablesReference: 0,
} as DebugProtocol.Variable)
variables.push({
name: id + '_f',
type: 'float',
value: '3.14',
variablesReference: 0,
})
variables.push({
name: id + '_f',
type: 'float',
value: '6.28',
variablesReference: 0,
})
variables.push({
name: id + '_f',
type: 'float',
value: '6.28',
variablesReference: 0,
})
variables.push({
name: id + '_s',
type: 'string',
value: 'hello world',
variablesReference: 0,
})
variables.push({
name: id + '_o',
type: 'object',
value: 'Object',
variablesReference: this._variableHandles.create(id + '_o'),
})
// cancellation support for long running requests
const nm = id + '_long_running'
const ref = this._variableHandles.create(id + '_lr')
variables.push({
name: nm,
type: 'object',
value: 'Object',
variablesReference: ref,
})
this._isLongrunning.set(ref, true)
}
}
response.body = {
variables: variables,
}
this.sendResponse(response)
}