From d041e89730f066e480c5f39e8508fad43c1db7f4 Mon Sep 17 00:00:00 2001 From: Mateo Date: Mon, 9 Sep 2024 13:33:39 +0200 Subject: [PATCH] refactor: cleanup code --- assets/cfg-arc-renderer.html | 31 +++--- assets/cfg-dot-renderer.html | 28 +++--- package.json | 17 ++-- src/lsp/cobol_cfg/cfg_builder.ml | 97 ++++++++----------- src/lsp/superbol_free_lib/vscode_extension.ml | 16 ++- .../superbol_cfg_explorer.ml | 53 +--------- .../superbol_cfg_explorer.mli | 7 +- .../superbol_commands.ml | 17 +--- 8 files changed, 87 insertions(+), 179 deletions(-) diff --git a/assets/cfg-arc-renderer.html b/assets/cfg-arc-renderer.html index f77ba5ec..ee13d23d 100644 --- a/assets/cfg-arc-renderer.html +++ b/assets/cfg-arc-renderer.html @@ -161,13 +161,13 @@ // List of node names const allNodes = data.nodes.map(d=>d.id).sort((a,b)=> a-b) - const sectionNames = data.nodes.filter(d=> !d.name.includes(" IN ")) + const sectionNames = data.nodes.filter(d => !d.name.includes(" IN ")) const color = d3.scaleOrdinal(sectionNames, d3.schemeCategory10) // A linear scale to position the nodes on the X axis y = d3.scalePoint() - .range([0, height]) - .domain(allNodes) + .range([0, height]) + .domain(allNodes) nodeColor = getNodeColor(color); @@ -199,8 +199,8 @@ .join('path') .attr('d', getLinkPath(y)) .style("fill", "none") - .attr("stroke", "black") - .attr("stroke-dasharray", getDasharray) + .style("stroke", "black") + .style("stroke-dasharray", getDasharray) // Add the circle for the nodes nodes = svg @@ -208,11 +208,20 @@ .data(data.nodes) .join("circle") .attr("cx", NODE_CENTER_X) - .attr("cy", d=>y(d.id)) + .attr("cy", d => y(d.id)) .attr("r", NODE_RADIUS) .style("fill", nodeColor) .style('stroke-width', 4) + svg + .selectAll("sectionnodes") + .data(sectionNames) + .join("circle") + .attr("cx", NODE_CENTER_X) + .attr("cy", d => y(d.id)) + .attr("r", 2) + .style("fill", "white") + // Add the highlighting functionality nodes .on('mouseover', (_, n) => focusNode(n)) @@ -233,13 +242,13 @@ graph = JSON.parse(event.data.graph) buildSVG(graph) break; - case "focused_proc": - const node = graph.nodes - .find(n => { return n.name === event.data.procedure }) - window.scroll(0, y(node.id)-window.innerHeight/3) + case "focused_proc": + const node = graph.nodes.find(n => n.name === event.data.procedure) + if(!node) return; + window.scroll(0, y(node.id) - window.innerHeight/3) focusNode(node) unfocus(5000) - break; + break; } }) diff --git a/assets/cfg-dot-renderer.html b/assets/cfg-dot-renderer.html index dba06a28..d8ebb765 100644 --- a/assets/cfg-dot-renderer.html +++ b/assets/cfg-dot-renderer.html @@ -70,7 +70,6 @@