Use createGraph to represent object graphs constructed from variables

This commit is contained in:
fwcd
2020-09-02 19:29:33 +02:00
parent 6ef0ecb60f
commit 4aca50f67a
2 changed files with 55 additions and 17 deletions

View File

@@ -1,17 +1,28 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>java</name>
<comment/>
<projects>&#xD;
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>&#xD;
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
</projectDescription>
<name>java</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.jdt.core.javabuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.jdt.core.javanature</nature>
</natures>
<filteredResources>
<filter>
<id>1599063072264</id>
<name></name>
<type>30</type>
<matcher>
<id>org.eclipse.core.resources.regexFilterMatcher</id>
<arguments>node_modules|.git|__CREATED_BY_JAVA_LANGUAGE_SERVER__</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

View File

@@ -1,4 +1,6 @@
import {
createGraph,
CreateGraphEdge,
DataExtractionResult,
DataExtractorId,
} from "@hediet/debug-visualizer-data-extraction";
@@ -49,6 +51,8 @@ export class GenericEvaluator implements Evaluator {
// Use structural information about variables
// from the evaluation response if present.
if (reply.variablesReference) {
let obj = await this.constructObjectFromVariablesReference(reply.variablesReference);
return {
kind: "data",
result: {
@@ -58,7 +62,30 @@ export class GenericEvaluator implements Evaluator {
name: "Generic",
priority: 1,
},
data: await this.constructObjectFromVariablesReference(reply.variablesReference),
data: createGraph(
[obj],
(item: any) => {
function isObject(val: any): boolean {
return val && typeof val === "object";
}
const edges = new Array<CreateGraphEdge<any>>();
for (const [key, val] of Object.entries(item)) {
if (isObject(val)) {
edges.push({ label: key, to: val });
}
}
const label = `${item}`;
return {
shape: "box",
edges,
color: item === obj ? "lightblue" : undefined,
label,
};
}
),
},
}
} else {