From abfa44b4f9addece1cc3b07b2294def04fa12db4 Mon Sep 17 00:00:00 2001 From: fwcd Date: Wed, 2 Sep 2020 17:28:08 +0200 Subject: [PATCH] Add new object construction in GenericEvaluationEngine --- .../GenericEvaluationEngine.ts | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts b/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts index 40e08d5..e14d07d 100644 --- a/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts +++ b/extension/src/EvaluationWatchService/EvaluationEngine/GenericEvaluationEngine.ts @@ -45,6 +45,27 @@ export class GenericEvaluator implements Evaluator { frameId, context: this.getContext(), }); + + // Use structural information about variables + // from the evaluation response if present. + if (reply.variablesReference) { + return { + kind: "data", + result: { + availableExtractors: [], + usedExtractor: { + id: "generic" as any, + name: "Generic", + priority: 1, + }, + data: await this.constructObjectFromVariablesReference(reply.variablesReference), + }, + } + } else { + return parseEvaluationResultFromGenericDebugAdapter(reply.result, { + debugAdapterType: this.session.session.configuration.type, + }); + } } catch (error) { return { kind: "error", @@ -65,10 +86,18 @@ export class GenericEvaluator implements Evaluator { }, }; } + } - return parseEvaluationResultFromGenericDebugAdapter(reply.result, { - debugAdapterType: this.session.session.configuration.type, - }); + private async constructObjectFromVariablesReference(variablesReference: number): Promise { + var result: any = {}; + for (const child of await this.session.getVariables({ variablesReference })) { + if (child.variablesReference > 0) { + result[child.name] = await this.constructObjectFromVariablesReference(child.variablesReference); + } else { + result[child.name] = child.value; + } + } + return result; } protected getFinalExpression(args: {