Skip to content

Commit 303adda

Browse files
Show constructor signatures on state machine arrows
1 parent 27fe8f9 commit 303adda

2 files changed

Lines changed: 8 additions & 4 deletions

File tree

‎client/src/types/fsm.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
export type LJStateMachine = {
44
className: string;
5-
initialTransitions: { to: string; toCondition?: string | null }[];
5+
initialTransitions: { to: string; toCondition?: string | null; constructorSignature?: string | null }[];
66
states: string[];
77
transitions: { from: string; to: string; label: string; fromCondition?: string | null; toCondition?: string | null }[];
88
errorContext: LJStateMachineErrorContext | null;

‎client/src/webview/diagram.ts‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export function createMermaidDiagram(
3535

3636
// initial transitions
3737
sm.initialTransitions.forEach(transition => {
38-
const label = getInitialTransitionLabel(transition.toCondition, showConditions);
38+
const label = getInitialTransitionLabel(transition.constructorSignature, transition.toCondition, showConditions);
3939
lines.push(` [*] --> ${transition.to}${label ? ` : ${label}` : ''}`);
4040
});
4141

@@ -89,8 +89,12 @@ function getTransitionLabel(
8989
].filter(Boolean).join('<br/>');
9090
}
9191

92-
function getInitialTransitionLabel(toCondition?: string | null, showConditions = false): string {
93-
return showConditions ? getConditionLabel('post', toCondition) : '';
92+
function getInitialTransitionLabel(constructorSignature?: string | null, toCondition?: string | null,
93+
showConditions = false): string {
94+
return [
95+
constructorSignature ? escapeMermaidLabel(constructorSignature) : '',
96+
showConditions ? getConditionLabel('post', toCondition) : '',
97+
].filter(Boolean).join('<br/>');
9498
}
9599

96100
function getConditionLabel(kind: 'pre' | 'post', cond?: string | null): string {

0 commit comments

Comments
 (0)