cursor
This commit is contained in:
@@ -429,11 +429,15 @@
|
||||
clearHighlights();
|
||||
const chains = metadata.metadata.callChains || [];
|
||||
|
||||
const seen = new Set();
|
||||
let steps = [];
|
||||
chains.forEach(c => {
|
||||
if (c.entryPoint.className === ep.className && c.entryPoint.methodName === ep.methodName) {
|
||||
if (c.matchedTransitions && c.matchedTransitions.length > 0) {
|
||||
c.matchedTransitions.forEach(t => {
|
||||
const key = buildLinkKey(t.sourceState, t.event);
|
||||
if (!key || seen.has(key)) return;
|
||||
seen.add(key);
|
||||
steps.push({ event: t.event, source: t.sourceState, ambiguous: c.triggerPoint && c.triggerPoint.ambiguous });
|
||||
});
|
||||
}
|
||||
@@ -459,22 +463,22 @@
|
||||
});
|
||||
|
||||
steps.forEach(step => {
|
||||
let targetEvent = "";
|
||||
let targetSource = "";
|
||||
let targetLinkKey = "";
|
||||
let targetAnon = "";
|
||||
let isAmbiguous = false;
|
||||
|
||||
if (typeof step === 'object') {
|
||||
targetEvent = normalize(step.event);
|
||||
targetSource = normalize(step.source);
|
||||
targetLinkKey = buildLinkKey(step.source, step.event);
|
||||
isAmbiguous = step.ambiguous;
|
||||
} else if (step.includes("->")) {
|
||||
const parts = step.split("->");
|
||||
targetAnon = "#link_anon_" + normalize(parts[0]) + "_" + normalize(parts[1]);
|
||||
} else {
|
||||
targetEvent = normalize(step);
|
||||
targetLinkKey = "__" + normalize(formatForLinkId(step));
|
||||
}
|
||||
|
||||
if (!targetLinkKey && !targetAnon) return;
|
||||
|
||||
svg.querySelectorAll('a').forEach(link => {
|
||||
const href = link.getAttribute('xlink:href') || link.getAttribute('href');
|
||||
if (!href) return;
|
||||
@@ -482,14 +486,11 @@
|
||||
let matches = false;
|
||||
if (targetAnon) {
|
||||
matches = (href === targetAnon);
|
||||
} else if (targetEvent) {
|
||||
if (targetSource) {
|
||||
// Exact match
|
||||
matches = (href === "#link_" + targetSource + "__" + targetEvent);
|
||||
} else {
|
||||
// Match all sources for this event
|
||||
matches = href.startsWith("#link_") && href.endsWith("__" + targetEvent);
|
||||
}
|
||||
} else if (targetLinkKey.includes("__")) {
|
||||
matches = (href === "#link_" + targetLinkKey);
|
||||
} else {
|
||||
// Business-flow step: event name only, match that event from any source
|
||||
matches = href.startsWith("#link_") && href.endsWith(targetLinkKey);
|
||||
}
|
||||
|
||||
if (matches) {
|
||||
@@ -570,8 +571,7 @@
|
||||
if (!t.event) return false;
|
||||
const evStr = t.event.fullIdentifier || t.event.rawName || t.event;
|
||||
const sourceStr = t.sourceStates && t.sourceStates.length > 0 ? (t.sourceStates[0].fullIdentifier || t.sourceStates[0].rawName) : "";
|
||||
const expectedLinkId = normalize(sourceStr) + "__" + normalize(evStr);
|
||||
return expectedLinkId === linkId;
|
||||
return buildLinkKey(sourceStr, evStr) === linkId;
|
||||
});
|
||||
if (metaTrans && metaTrans.event) {
|
||||
cleanEventName = metaTrans.event.fullIdentifier || metaTrans.event.rawName || metaTrans.event;
|
||||
@@ -602,17 +602,37 @@
|
||||
});
|
||||
}
|
||||
|
||||
function formatForLinkId(identifier) {
|
||||
if (!identifier) return "";
|
||||
const s = String(identifier);
|
||||
const lastDot = s.lastIndexOf('.');
|
||||
if (lastDot <= 0) return s;
|
||||
const prevDot = s.lastIndexOf('.', lastDot - 1);
|
||||
return prevDot > 0 ? s.substring(prevDot + 1) : s;
|
||||
}
|
||||
|
||||
function normalize(s) {
|
||||
if (!s) return "";
|
||||
return s.replace(/[^a-zA-Z0-9]/g, '_');
|
||||
}
|
||||
|
||||
function buildLinkKey(source, event) {
|
||||
if (!event) return "";
|
||||
const formattedEvent = formatForLinkId(event);
|
||||
if (!source) return "__" + normalize(formattedEvent);
|
||||
return normalize(formatForLinkId(source)) + "__" + normalize(formattedEvent);
|
||||
}
|
||||
|
||||
function eventsMatchForLink(a, b) {
|
||||
return normalize(formatForLinkId(a)) === normalize(formatForLinkId(b));
|
||||
}
|
||||
|
||||
function createTooltip(name, trans) {
|
||||
const chains = (metadata.metadata.callChains || []).filter(c => {
|
||||
if (!c.matchedTransitions || c.matchedTransitions.length === 0) return false;
|
||||
return c.matchedTransitions.some(t => {
|
||||
const cEventStr = typeof t.event === 'object' ? (t.event.fullIdentifier || t.event.rawName || t.event) : t.event;
|
||||
return normalize(cEventStr) === normalize(name);
|
||||
return eventsMatchForLink(cEventStr, name);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user