/** * Running a validation and saying what came of it: the validate button and * the tracker behind it, the query tracker a slurp writes through, the * capture-and-replay debugger, and what a failure is reported as. Mixed * onto ShExBaseApp; see ShExBaseApp.js. * * This is doc/ShExBaseApp-validation.js's source (tsconfig.app.json compiles src/app/ into * doc/); edit here and run `npm run build`. */ mixin(ShExBaseApp, { // abstract getValidator (_validator) { } // overriden for ShExMap /** * resolve node and shape against input data and schema base and prefixes */ fixValidationShapeMapEntry(node, shape) { return { node: this.Caches.inputData.meta.lexToTerm(node), shape: this.Caches.inputSchema.meta.lexToTerm(shape) // resolve with this.Caches.outputSchema }; }, /** reveal the shared floating debug panel for `mode` ("replay" | * "live" | "materialize"): show the rows that mode uses, hide the rest, * enable the step verbs, and stand the trigger buttons down. */ showDebugPanel(mode) { $("#debugPanel").show(); // the card names which debugger it is driving (the title was a fixed // "debugger" before -- it now says what is being stepped) $("#debugPanelTitle").text(mode === "materialize" ? "materialization" : mode === "live" ? "live validation" : "validation"); this.setDebugRunnable(true); // a replay steps within one match, so it can't step out; validation and // materialization walk a call tree and can $("#dbgOut").toggle(mode !== "replay"); // the bp/bn breakpoint entry is the validators'; the recorded-match // picker is capture+replay's alone $("#dbgMatchesRow").toggle(mode !== "materialize"); $("#dbgMatches").toggle(mode === "replay"); $("#dbgStatusRow, #dbgThreadsRow").show(); $("#dbgOver").attr("title", mode === "live" ? "step over this shape's body" : mode === "materialize" ? "step over" : "run to the next generation"); $("#debugValidate, #debugValidateLive, #debugMaterialize").hide(); }, /** hide the panel and offer the triggers again (live only where the page * is cross-origin isolated) */ hideDebugPanel() { $("#debugPanel").hide(); $("#dbgStatus").text(""); $("#dbgThreads, #dbgBreakpoints").empty(); $("#debugValidate, #debugMaterialize").show(); // #debugMaterialize is a no-op without the plugin if (typeof SharedArrayBuffer !== "undefined" && typeof self !== "undefined" && self.crossOriginIsolated) $("#debugValidateLive").show(); }, /** enable or disable the step verbs (▶⤵⏭⤴): disabled once a search is * exhausted, so a dead button reads as done rather than doing nothing */ setDebugRunnable(runnable) { $("#dbgContinue, #dbgInto, #dbgOver, #dbgOut").prop("disabled", !runnable); }, /** end whichever debug session is running -- called when the ground moves * under it (the schema or data is re-picked) */ endActiveDebugSession() { if (this.activeDebugSession) this.activeDebugSession.end(); }, /* Executions */ // Validation UI /** a validation is starting: an app with results derived from the last * one says so here. Nothing to do for a validator. */ startingValidation() { pluginDescriptors().forEach(ext => { if (typeof ext.onStartingValidation === "function") ext.onStartingValidation(this); }); }, disableResultsAndValidate(evt) { if (new Date().getTime() - LastFailTime < 100) { this.resultsWidget.append($("
").addClass("warning").append($("").text("see shape map errors above"), $("").text("validate (ctl-enter)").on("click", this.disableResultsAndValidate.bind(this)), " again to continue.")); return; // return if < 100ms since last error. } // a validation replaces whatever the last one produced, including // anything an app derived from it (see ShExMapBaseApp) -- and including // a debug session, whose recorded matches belong to the results about to // be thrown away. This is not "continue, ignoring breakpoints": that is // ▶, which resumes the recorded match; this re-runs the whole validation // and rebuilds the results underneath it. this.endValidationDebugSession(); this.startingValidation(); this.resultsWidget.clear(); this.resultsWidget.start(); // Say what is happening before it starts, and let the browser paint it: // a validation over a synchronous neighborhood holds the main thread // from here until it is done, so this is the last chance to draw // anything. (Which is also why the elapsed time is reported after // rather than counted up during -- see doc/ShExBaseApp.js's // startValidation.) this.startValidation(); this.track(new Promise((resolve, reject) => { setTimeout(async () => { const began = new Date().getTime(); try { const errors = await this.Caches.shapeMap.copyEditMapToQueryMap(); // will update if #editMap is dirty if (errors.length === 0) resolve(await this.callValidator()); else resolve({ shapeMapErrors: errors }); // settled either way: a waiter must not hang on a bad map } finally { this.endValidation(new Date().getTime() - began); } }, 0); })); }, /** the validate button while a validation is running: it is the only * thing that can be said, since nothing will repaint until it finishes */ startValidation() { $("#validate").addClass("running").prop("disabled", true) .text("validating\u2026").attr("title", ""); }, endValidation(elapsed) { $("#validate").removeClass("running").prop("disabled", false) .text(VALIDATE_LABEL) .attr("title", "last validation: " + elapsed + " ms"); }, /** startValidationDebugSession - step-through debugging of the * triple-expression matches in a validation (doc/debugger-design.md): * the validation runs to completion with the selected regex engine * recording every regexEngine.match() invocation; any of them can then * be replayed one NFA event at a time by eval-simple-1err's stepper (a * fresh one per match where the selected engine is another), the * semantic actions answering from the recording rather than running * again. Gutter breakpoints in the schema pane become constraint * breakpoints. A validation thread's aspects are its position in the * state machine, its repeat counts and its matched-triples partition -- * previewValThread renders them. */ async startValidationDebugSession() { const pane = this.editorSupport && this.editorSupport.panes.inputSchema; if (!pane) { this.resultsWidget.replace("Enable the language-aware editors (Menu → user interface) to debug validation.") .removeClass("passes fails").addClass("error"); return null; } this.resultsWidget.clear(); let currentAction = "starting validation debugger"; try { currentAction = "parsing input schema"; const schema = await this.Caches.inputSchema.refresh(); currentAction = "parsing input data"; const inputData = await this.Caches.inputData.refresh(); currentAction = "parsing shape map"; const fixedMap = $("#fixedMap tr").map((idx, tr) => this.fixValidationShapeMapEntry($(tr).find("input.focus").val(), $(tr).find("input.inputShape").val())).get(); if (fixedMap.length === 0) { this.resultsWidget.replace("Add a node@shape pair to the fixed shape map to debug its validation.") .removeClass("passes fails").addClass("error"); return null; } currentAction = "validating (recording matches)"; const schemaText = this.Caches.inputSchema.selection.val(); const located = ShExWebApp.EditorServices.locateInParsed(schemaText, schema); const selected = ShExWebApp[$("#regexpEngine").val()] || ShExWebApp["eval-threaded-nerr"]; const { module, captures } = ShExWebApp.capturingRegexModule(selected); const validator = new ShExWebApp.Validator(schema, inputData, { results: "api", regexModule: module, ignoreClosed: $("#ignoreClosed").is(":checked"), }); const results = validator.validateShapeMap(fixedMap); if (captures.length === 0) { this.resultsWidget.replace("This validation never matched a triple expression (nothing to step through).") .removeClass("passes fails").addClass("error"); return null; } // breakpoints beyond the gutter's: by predicate, and by node (which // is which recorded matches to offer) const breakpoints = this.valDebugSession && this.valDebugSession.breakpoints || { predicates: new Set(), nodes: new Set() }; if (this.activeDebugSession) this.activeDebugSession.end(); this.valDebugSession = { kind: "replay", captures, located, pane, schema, results, breakpoints }; // the shared control strip drives whichever session is live (a // materialization debugger runs here too, one at a time) this.activeDebugSession = { kind: "replay", step: (c) => this.valDebugStep(c), end: () => this.endValidationDebugSession() }; const select = $("#dbgMatches").empty(); captures.forEach((cap, i) => select.append($("", { value: i }).text(this.matchCaptureLabel(cap, schema)))); select.off("change").on("change", () => this.pickValidationMatch(parseInt(select.val(), 10))); this.renderValDebugBreakpoints(); // 🐞 started this session, and pressing it again would only start // another over the same results this.showDebugPanel("replay"); this.pickValidationMatch(this.offeredMatches()[0] || 0); return this.valDebugSession; } catch (e) { this.reportValidationError(e, currentAction); return null; } }, /** * Live whole-validation stepping (doc/debugger-design.md §4), the * companion to the capture+replay 🐞 above. Where that reruns the * finished validation and replays one triple-expression match, this steps * the *whole* validation as it runs -- every shape entered and left, every * constraint considered -- by running the validator in a dedicated worker * that blocks on Atomics.wait between events (WorkerGate) while this thread * drives it over a SharedArrayBuffer (GateController). It needs * cross-origin isolation for SharedArrayBuffer (shex-serve --coi), so the * 🐞▶ button offering it appears only there. It reuses this panel's step * controls, its gutter/predicate/node breakpoints and its status line; the * recorded-match picker has no place here (there is one running validation, * not a catalogue of matches) and is hidden. * * Breakpoints are frozen while the worker runs and adopted afresh at each * resume: currentValWireBreakpoints() reads the live gutter and chips every * time a step is sent, so a breakpoint added while paused takes effect on * the next move and none is read mid-search. */ async startValidationDebugSessionLive() { const pane = this.editorSupport && this.editorSupport.panes.inputSchema; if (!pane) { this.resultsWidget.replace("Enable the language-aware editors (Menu → user interface) to debug validation.") .removeClass("passes fails").addClass("error"); return null; } if (typeof SharedArrayBuffer === "undefined" || typeof self === "undefined" || !self.crossOriginIsolated) { this.resultsWidget.replace("Live validation stepping needs cross-origin isolation (SharedArrayBuffer); serve the app with shex-serve --coi.") .removeClass("passes fails").addClass("error"); return null; } this.resultsWidget.clear(); let currentAction = "starting the live validation debugger"; try { currentAction = "parsing input schema"; const schema = await this.Caches.inputSchema.refresh(); currentAction = "parsing input data"; const inputData = await this.Caches.inputData.refresh(); currentAction = "parsing shape map"; const fixedMap = $("#fixedMap tr").map((idx, tr) => this.fixValidationShapeMapEntry($(tr).find("input.focus").val(), $(tr).find("input.inputShape").val())).get(); if (fixedMap.length === 0) { this.resultsWidget.replace("Add a node@shape pair to the fixed shape map to debug its validation.") .removeClass("passes fails").addClass("error"); return null; } // the worker validates a static db it is handed; a source that fetches // its neighborhoods as the walk needs them can't be stepped this way const quads = inputData.getQuads(); if (quads.length === 0) { this.resultsWidget.replace("Live stepping validates the data in the pane; load some triples (a fetching source has none to hand the worker).") .removeClass("passes fails").addClass("error"); return null; } const schemaText = this.Caches.inputSchema.selection.val(); const located = ShExWebApp.EditorServices.locateInParsed(schemaText, schema); const tcs = ShExWebApp.schemaTripleConstraints(schema); const sab = ShExWebApp.createCommandBuffer(); const controller = new ShExWebApp.GateController(sab); // carry any predicate/node breakpoints across from a prior session const breakpoints = this.valDebugSession && this.valDebugSession.breakpoints || { predicates: new Set(), nodes: new Set() }; // a dedicated worker, independent of the app's ShExWorker: it runs only // this gated validation and is terminated when the session ends, so it // never disturbs the validator the app may hold in its own worker if (this.activeDebugSession) this.activeDebugSession.end(); const worker = new Worker(WorkerUrl); const session = { live: true, located, pane, schema, tcs, controller, sab, breakpoints, worker, done: false, currentEvent: null }; this.valDebugSession = session; this.activeDebugSession = { kind: "live", step: (c) => this.valDebugStep(c), end: () => this.endValidationDebugSession() }; worker.onmessage = (msg) => this.receiveLiveValDebug(msg); worker.onerror = (e) => { $("#dbgStatus").text("worker error: " + ((e && e.message) || e)); session.done = true; }; worker.postMessage(Object.assign({ plugins: pluginWorkerUrls() }, { request: "debugValidate", schema, data: quads.map((t) => WorkerMarshalling.rdfjsTripleToJsonTriple(t)), queryMap: fixedMap.map((e) => ({ node: e.node, shape: e.shape })), options: { regexModule: $("#regexpEngine").val(), ignoreClosed: $("#ignoreClosed").is(":checked") }, sab, })); this.renderValDebugBreakpoints(); this.showDebugPanel("live"); $("#dbgStatus").text("starting the validation in a worker..."); return session; } catch (e) { this.reportValidationError(e, currentAction); return null; } }, /** a message from the live debug worker: a pause to render, or the run's * end. Steps are sent back over the SAB (valDebugStep), never as a * message -- a worker blocked in Atomics.wait can't read one. */ receiveLiveValDebug(msg) { const session = this.valDebugSession; if (!session || !session.live || msg.data.request) // request: a message we posted, echoed return; switch (msg.data.response) { case "paused": session.currentEvent = msg.data.event; this.showLiveValDebugEvent(msg.data.event); break; case "done": session.done = true; this.setDebugRunnable(false); // the walk is over; only ⏹ is live session.pane.clearHighlights(); $("#dbgStatus").text("validation finished: " + (msg.data.conformant ? "conformant" : "nonconformant") + "; ⏹ to close"); break; case "aborted": session.done = true; this.setDebugRunnable(false); session.pane.clearHighlights(); $("#dbgStatus").text("validation debugger stopped"); break; case "error": session.done = true; this.setDebugRunnable(false); $("#dbgStatus").text("worker error: " + (msg.data.message || "?")); break; } }, /** render a paused gate event (a SerializedGateEvent from the worker): * the status line and the current-position highlight. A constraint is * named across the postMessage by its ordinal in schemaTripleConstraints, * which indexes this side's own copy back to the object to highlight. */ showLiveValDebugEvent(event) { const session = this.valDebugSession; if (!event || !session) return; const at = event.node ? (event.node.termType === "BlankNode" ? "_:" + event.node.value : "<" + event.node.value + ">") : ""; const shapeOf = (label) => { const locate = session.located.locate; const hit = locate.shape ? locate.shape(label) : null; session.pane.highlight(hit ? [hit] : [], "shexjs-debug-current"); }; switch (event.type) { case "enter": $("#dbgStatus").text("enter " + at + "@<" + event.shape + "> [depth " + event.depth + "]"); shapeOf(event.shape); break; case "constraint": { $("#dbgStatus").text("at <" + event.predicate + "> for " + at + " (" + event.candidates + " candidate" + (event.candidates === 1 ? "" : "s") + ")" + " [depth " + event.depth + "]"); const tc = session.tcs[event.tcOrdinal]; const range = tc ? session.located.locate.expr(tc) : null; session.pane.highlight(range ? [range] : [], "shexjs-debug-current"); break; } case "exit": $("#dbgStatus").text("exit " + at + "@<" + event.shape + "> -> " + (event.ok ? "ok" : "fail") + " [depth " + event.depth + "]"); shapeOf(event.shape); break; case "recurse": $("#dbgStatus").text("recurse into <" + event.shape + "> [depth " + event.depth + "]"); shapeOf(event.shape); break; } }, /** the breakpoints a live resume carries, read fresh from the panel so a * change while paused takes effect on the next step (the frozen/editable * model): gutter dots resolved to constraint ordinals (the clone-safe key * the worker shares), plus the predicate and node chips. */ currentValWireBreakpoints() { const session = this.valDebugSession; if (!session) return {}; const constraints = []; const schemaText = this.Caches.inputSchema.selection.val(); const lineStarts = ShExWebApp.EditorServices.lineOffsets(schemaText); session.pane.listBreakpoints().forEach((pos) => { const next = lineStarts.findIndex((start) => start > pos); const lineFrom = lineStarts[(next === -1 ? lineStarts.length : next) - 1]; const lineEnd = next === -1 ? schemaText.length : lineStarts[next]; let hit = null; if (pos === lineFrom) { hit = session.located.locate.exprsStartingIn(lineFrom, lineEnd)[0] || null; for (let offset = lineFrom; offset < lineEnd && !hit; ++offset) hit = session.located.locate.exprAt(offset); } else { hit = session.located.locate.exprAt(pos); } if (hit) { const ord = session.tcs.indexOf(hit.expr); if (ord !== -1) constraints.push(ord); } }); return { constraints, predicates: Array.from(session.breakpoints.predicates), nodes: Array.from(session.breakpoints.nodes), }; }, matchCaptureLabel(cap, schema) { const index = schema._index || {}; const label = Object.keys(index.shapeExprs || {}).find(l => { const decl = index.shapeExprs[l]; return decl === cap.shape || decl.shapeExpr === cap.shape; }); const node = cap.node.termType === "BlankNode" ? "_:" + cap.node.value : cap.node.value; return node + "@" + (label || "?"); }, /** the node a recorded match is about, as a breakpoint names it */ captureNodeLex(cap) { return cap.node.termType === "BlankNode" ? "_:" + cap.node.value : cap.node.value; }, /** the recorded matches a node breakpoint leaves on offer (all, with * none set); the picker shows only these */ offeredMatches() { const session = this.valDebugSession; if (!session) return []; const nodes = session.breakpoints.nodes; const offered = []; session.captures.forEach((cap, i) => { const on = nodes.size === 0 || nodes.has(this.captureNodeLex(cap)); $("#dbgMatches option[value='" + i + "']").toggle(on); if (on) offered.push(i); }); return offered; }, /** * A breakpoint said in words, as shex-debug takes them: `bp PREDICATE` * pauses at every constraint with that predicate, `bn NODE` keeps only * the recorded matches on that node. Prefixed names read against the * schema's prefixes (a predicate) or the data's (a node). */ addValDebugBreakpoint(text) { const session = this.valDebugSession; const m = (text || "").trim().match(/^(bp|bn)\s+(\S+)$/); if (!session || !m) { $("#dbgStatus").text("a breakpoint is bp PREDICATE or bn NODE"); return false; } const [, kind, lex] = m; try { if (kind === "bp") { const iri = this.Caches.inputSchema.meta.lexToTerm(lex); session.breakpoints.predicates.add(typeof iri === "string" ? iri : lex); } else { const term = lex.startsWith("_:") ? lex : this.Caches.inputData.meta.lexToTerm(lex); session.breakpoints.nodes.add(typeof term === "string" ? term : lex); } } catch (e) { $("#dbgStatus").text("no such " + (kind === "bp" ? "predicate" : "node") + ": " + e.message); return false; } this.renderValDebugBreakpoints(); // re-arm, on a match still on offer const offered = this.offeredMatches(); const current = parseInt($("#dbgMatches").val(), 10); this.pickValidationMatch(offered.indexOf(current) === -1 ? (offered[0] || 0) : current); return true; }, removeValDebugBreakpoint(kind, value) { const session = this.valDebugSession; if (!session) return; session.breakpoints[kind === "bp" ? "predicates" : "nodes"].delete(value); this.renderValDebugBreakpoints(); const offered = this.offeredMatches(); const current = parseInt($("#dbgMatches").val(), 10); this.pickValidationMatch(offered.indexOf(current) === -1 ? (offered[0] || 0) : current); }, /** the breakpoints as chips, each with its × */ renderValDebugBreakpoints() { const session = this.valDebugSession; const list = $("#dbgBreakpoints").empty(); if (!session) return; const lex = (iri, meta) => { try { return meta.termToLex(iri); } catch (e) { return iri; } }; [["bp", session.breakpoints.predicates, this.Caches.inputSchema.meta], ["bn", session.breakpoints.nodes, this.Caches.inputData.meta]].forEach(([kind, set, meta]) => { set.forEach((value) => { list.append($("", { class: "dbgBreakpoint", "data-kind": kind, "data-value": value }) .text(kind + " " + (typeof value === "string" && !value.startsWith("_:") ? lex(value, meta) : value)) .append($("", { title: "remove this breakpoint" }).text("×") .on("click", () => this.removeValDebugBreakpoint(kind, value)))); }); }); }, /** ctrl-alt-b: a breakpoint on the constraint at the schema pane's * cursor -- for a line that holds several, whose gutter can name only * the first */ toggleBreakpointAtCursor() { const pane = this.editorSupport && this.editorSupport.panes.inputSchema; if (!pane || !pane.view) return false; pane.toggleBreakpointAt(pane.view.state.selection.main.head); if (this.valDebugSession) // re-arm, so it counts from here on this.pickValidationMatch(parseInt($("#dbgMatches").val(), 10) || 0); return true; }, /** (re)arm the debugger on one recorded match */ pickValidationMatch(captureNo) { const session = this.valDebugSession; if (!session) return null; $("#dbgMatches").val(String(captureNo)); const cap = session.captures[captureNo]; // only eval-simple-1err's engine steps: a match another engine ran is // replayed by a fresh one over the same inputs const stepper = ShExWebApp["eval-simple-1err"]; const engine = cap.regexModule === stepper.name ? cap.engine : stepper.compile(session.schema, cap.shape, session.schema._index); const dbg = new ShExWebApp.MatchDebugger(engine, cap.node, cap.constraintToTripleMapping, ShExWebApp.replayingSemActHandler(cap.semActLog, cap.semActHandler)); // A breakpoint set in the gutter sits at its line's start and means // the first constraint the line *begins* -- not one that started // above and continues across it -- falling back to whatever the line // is inside of where it begins none. One set at a position (ctrl-alt-b) // means the constraint there. const schemaText = this.Caches.inputSchema.selection.val(); const lineStarts = ShExWebApp.EditorServices.lineOffsets(schemaText); session.pane.listBreakpoints().forEach((pos) => { const next = lineStarts.findIndex((start) => start > pos); const lineFrom = lineStarts[(next === -1 ? lineStarts.length : next) - 1]; const lineEnd = next === -1 ? schemaText.length : lineStarts[next]; let hit = null; if (pos === lineFrom) { hit = session.located.locate.exprsStartingIn(lineFrom, lineEnd)[0] || null; for (let offset = lineFrom; offset < lineEnd && !hit; ++offset) hit = session.located.locate.exprAt(offset); } else { hit = session.located.locate.exprAt(pos); } if (hit) dbg.addBreakpoint({ tc: hit.expr }); }); session.breakpoints.predicates.forEach((predicate) => dbg.addBreakpoint({ predicate })); session.dbg = dbg; session.capture = cap; this.setDebugRunnable(true); // a fresh match to step (re-arms after one finished) $("#dbgStatus").text("paused before matching " + $("#dbgMatches option:selected").text() + "; step or continue" + (cap.regexModule === stepper.name ? "" : " (captured with " + cap.regexModule + ", replayed with " + stepper.name + ")")); $("#dbgThreads").empty(); return dbg; }, valDebugStep(command) { const session = this.valDebugSession; if (!session) return null; // live mode: send the step over the SAB (with the current breakpoints) // and wait -- the next event arrives as a "paused" worker message if (session.live) { if (session.done) return null; // the run is over; ⏹ closes the panel const bp = this.currentValWireBreakpoints(); if (command === "stepInto") session.controller.into(bp); else if (command === "stepOver") session.controller.over(bp); else if (command === "stepOut") session.controller.out(bp); else if (command === "continue") session.controller.continue(bp); return null; } // capture+replay steps within one match: it has stepInto/stepOver/ // continue but no stepOut (⤴ is hidden for it) if (!session.dbg || typeof session.dbg[command] !== "function") return null; const event = session.dbg[command](); this.showValDebugEvent(event); this.updateValThreadList(); return event; }, showValDebugEvent(event) { const session = this.valDebugSession; if (!event || !session) return; const threadStr = event.thread ? " [state:" + event.thread.stateNo + " matched:" + event.thread.matched.reduce((n, m) => n + m.triples.length, 0) + (Object.keys(event.thread.repeats).length ? " repeats:" + JSON.stringify(event.thread.repeats) : "") + "]" : ""; const gen = "generation" in event ? " gen:" + event.generation : ""; switch (event.type) { case "constraint": { $("#dbgStatus").text("at <" + event.tc.predicate + ">" + gen + threadStr); const range = session.located.locate.expr(event.tc); session.pane.highlight(range ? [range] : [], "shexjs-debug-current"); break; } case "fail": $("#dbgStatus").text("thread died at <" + event.tc.predicate + ">" + gen + threadStr); break; case "accept": $("#dbgStatus").text("thread accepted" + gen + threadStr); break; case "done": this.setDebugRunnable(false); // this match is exhausted; pick another to re-arm $("#dbgStatus").text("match finished: " + (session.dbg.result && !("errors" in session.dbg.result) ? "matched" : "failed") + "; pick another match or ⏹"); session.pane.clearHighlights(); break; case "error": $("#dbgStatus").text("failed: " + event.error.message); break; } }, /** the debugger's threads pane: this generation's threads (• = already * advanced into the next); hover or click renders a thread's aspects */ updateValThreadList() { const session = this.valDebugSession; const list = $("#dbgThreads").empty(); if (!session || !session.dbg) return; session.dbg.threads().forEach((t) => { const label = (t.next ? "advanced" : "current") + " thread at state " + t.stateNo + (t.tc ? " <" + t.tc.predicate + ">" : " (" + t.at + ")"); list.append($("", { class: "dbgThread", title: label + " -- click for its state" }) .text((t.next ? "•" : "") + "s" + t.stateNo) .on("mouseenter click", () => this.previewValThread(t, label))); }); }, /** the aspects specific to a validation thread: position in the state * machine (highlighted in the schema pane), repeat counts, and the * partition of matched triples (highlighted in the data pane, and * listed) */ previewValThread(t, label) { const session = this.valDebugSession; if (!session) return; if (t.tc) { const range = session.located.locate.expr(t.tc); session.pane.highlight(range ? [range] : [], "shexjs-debug-current"); } const dataPane = this.editorSupport && this.editorSupport.panes.inputData; if (dataPane) { const located = this.editorSupport.locateData(this.Caches.inputData.selection.val()); const ranges = !located ? [] : t.matched.flatMap((m) => m.quads || []) .map((q) => ShExWebApp.EditorServices.quadRanges(located, q)) .filter((a) => a) .flatMap((a) => [a.object, a.subject, a.predicate].filter(r => r)); dataPane.highlight(ranges, "shexjs-debug-current"); } // ...and a table of the rest: where it is, its repeat counts, the // partition it has committed to, constraint by constraint const lex = (iri) => { try { return this.Caches.inputSchema.meta.termToLex(iri); } catch (e) { return "<" + iri + ">"; } }; const row = (th, td) => $("