feat(debug): enhance type hinting in gdb and Python debug visualizers
This commit is contained in:
@@ -34,6 +34,7 @@ module.exports = function (register, lib) {
|
||||
var sNode = sj.sOpenObject({
|
||||
id: sj.sString(),
|
||||
fields: sj.sArrayOf(sField),
|
||||
type: sj.sOptionalProp(sj.sString(), {}),
|
||||
});
|
||||
|
||||
var sEdge = sj.sOpenObject({
|
||||
@@ -572,7 +573,18 @@ module.exports = function (register, lib) {
|
||||
textOverflow: "ellipsis",
|
||||
minWidth: "0",
|
||||
});
|
||||
headerLabel.textContent = n.id;
|
||||
headerLabel.appendChild(document.createTextNode(n.id));
|
||||
if (n.type) {
|
||||
var nodeTypeSpan = el("span", {
|
||||
color: colors.fieldType,
|
||||
fontSize: "10px",
|
||||
fontWeight: "normal",
|
||||
marginLeft: "6px",
|
||||
});
|
||||
nodeTypeSpan.textContent = n.type;
|
||||
headerLabel.appendChild(nodeTypeSpan);
|
||||
header.title = n.id + " : " + n.type;
|
||||
}
|
||||
header.appendChild(headerLabel);
|
||||
|
||||
var kids = childrenOf[n.id];
|
||||
@@ -752,7 +764,6 @@ module.exports = function (register, lib) {
|
||||
|
||||
return { root: r, kind: rootKind(r), badge: box, line: null, matched: false, height: height, x: 0, y: 0, pinned: false };
|
||||
});
|
||||
var nextUnmatchedX = 0;
|
||||
var badgesPerTarget = {};
|
||||
|
||||
viewport.appendChild(world);
|
||||
@@ -1035,7 +1046,26 @@ module.exports = function (register, lib) {
|
||||
}
|
||||
});
|
||||
|
||||
nextUnmatchedX = 0;
|
||||
// Unmatched-root cards (plain scalar locals/globals/watches) that
|
||||
// aren't pinned by a drag auto-flow into a compact roughly-square
|
||||
// cluster -- sqrt(count) columns -- instead of one ever-widening
|
||||
// row, so a handful of locals reads as a group near the top
|
||||
// instead of a line stretching off to the side. The cluster's
|
||||
// bottom row sits just above the node cloud (same non-overlap
|
||||
// tracking as before); earlier rows stack upward from there.
|
||||
var unmatchedFlow = rootBadges.filter(function (rb) {
|
||||
return !rb.matched && !rb.pinned && rootKindEnabled[rb.kind];
|
||||
});
|
||||
var flowCols = Math.max(1, Math.ceil(Math.sqrt(unmatchedFlow.length)));
|
||||
var flowRows = Math.ceil(unmatchedFlow.length / flowCols);
|
||||
var flowRowHeight = 0;
|
||||
unmatchedFlow.forEach(function (rb) {
|
||||
flowRowHeight = Math.max(flowRowHeight, rb.height);
|
||||
});
|
||||
var flowRowGap = 10;
|
||||
var flowShelfBottom = (visibleTopY === Infinity ? 0 : visibleTopY) - ROOT_GAP;
|
||||
var flowIndex = 0;
|
||||
|
||||
badgesPerTarget = {};
|
||||
rootBadges.forEach(function (rb) {
|
||||
if (!rootKindEnabled[rb.kind]) {
|
||||
@@ -1067,21 +1097,18 @@ module.exports = function (register, lib) {
|
||||
} else {
|
||||
rb.badge.style.display = "";
|
||||
if (!rb.pinned) {
|
||||
rb.x = nextUnmatchedX;
|
||||
// Sit just above whatever's currently the top of the
|
||||
// visible node cloud, rather than a fixed world y --
|
||||
// so this shelf of scalar-local cards tracks the
|
||||
// graph instead of drifting into overlapping it once
|
||||
// "auto" physics (or gravity re-centering) moves
|
||||
// nodes around.
|
||||
var shelfTop = (visibleTopY === Infinity ? 0 : visibleTopY) - ROOT_GAP;
|
||||
rb.y = shelfTop - rb.height;
|
||||
nextUnmatchedX += NODE_WIDTH + 20;
|
||||
var row = Math.floor(flowIndex / flowCols); // 0 = top row
|
||||
var col = flowIndex % flowCols;
|
||||
var rowFromBottom = flowRows - 1 - row; // 0 = row nearest the graph
|
||||
var rowBottom = flowShelfBottom - rowFromBottom * (flowRowHeight + flowRowGap);
|
||||
rb.x = col * (NODE_WIDTH + 20);
|
||||
rb.y = rowBottom - rb.height;
|
||||
flowIndex++;
|
||||
}
|
||||
// A pinned (user-dragged) card keeps whatever rb.x/rb.y
|
||||
// the drag left it at, and drops out of the auto-flow
|
||||
// row entirely -- the remaining unpinned cards close the
|
||||
// gap instead of leaving a hole where it used to sit.
|
||||
// cluster entirely -- the remaining unpinned cards
|
||||
// re-flow to close the gap instead of leaving a hole.
|
||||
rb.badge.style.left = rb.x + "px";
|
||||
rb.badge.style.top = rb.y + "px";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user