diff --git a/src/sdfg_diff_viewer.ts b/src/sdfg_diff_viewer.ts index 914be54..c97dbfe 100644 --- a/src/sdfg_diff_viewer.ts +++ b/src/sdfg_diff_viewer.ts @@ -318,7 +318,7 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer { ); } - public static init(graphA: JsonSDFG, graphB: JsonSDFG): WebSDFGDiffViewer { + public static init(graphA: JsonSDFG, graphB: JsonSDFG, precomputedDiff?: DiffMap): WebSDFGDiffViewer { const leftContainer = document.getElementById('diff-contents-A'); const rightContainer = document.getElementById('diff-contents-B'); if (!leftContainer || !rightContainer) @@ -426,7 +426,8 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer { lSDFG.sdfgDagreGraph = leftRenderer.get_graph() ?? undefined; const rSDFG = new SDFG(graphB); rSDFG.sdfgDagreGraph = rightRenderer.get_graph() ?? undefined; - SDFGDiffViewer.diff(lSDFG, rSDFG).then(diff => { + + const onDiffCreated = (diff: DiffMap) => { viewer.diffMap = diff; const leftOverlay = new DiffOverlay(leftRenderer, diff); const rightOverlay = new DiffOverlay(rightRenderer, diff); @@ -436,7 +437,15 @@ export class WebSDFGDiffViewer extends SDFGDiffViewer { rightRenderer.overlayManager.register_overlay_instance( rightOverlay ); - }); + }; + + if (precomputedDiff) { + onDiffCreated(precomputedDiff); + } else { + SDFGDiffViewer.diff(lSDFG, rSDFG).then(diff => { + onDiffCreated(diff); + }); + } return viewer; } diff --git a/src/sdfv.ts b/src/sdfv.ts index 42a2bd9..fa181c5 100644 --- a/src/sdfv.ts +++ b/src/sdfv.ts @@ -35,7 +35,7 @@ import { stringify_sdfg, } from './utils/sdfg/json_serializer'; import { SDFVSettings } from './utils/sdfv_settings'; -import { WebSDFGDiffViewer } from './sdfg_diff_viewer'; +import { DiffMap, WebSDFGDiffViewer } from './sdfg_diff_viewer'; import { ISDFVUserInterface, SDFVWebUI } from './sdfv_ui'; declare const vscode: any; @@ -244,7 +244,7 @@ export class WebSDFV extends SDFV { fileReader.readAsArrayBuffer(this.currentSDFGFile); } - public enterDiffView(sdfgA: JsonSDFG, sdfgB: JsonSDFG): void { + public enterDiffView(sdfgA: JsonSDFG, sdfgB: JsonSDFG, precomputedDiff?: DiffMap): void { $('#contents').hide(); this.renderer?.destroy(); @@ -252,7 +252,7 @@ export class WebSDFV extends SDFV { this.UI.infoClear(); this.deregisterEventListeners(); - WebSDFGDiffViewer.init(sdfgA, sdfgB); + WebSDFGDiffViewer.init(sdfgA, sdfgB, precomputedDiff); $('#diff-container').show(); }