@domainlang/language 0.11.0 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/out/diagram/context-map-diagram-generator.d.ts +65 -0
- package/out/diagram/context-map-diagram-generator.js +356 -0
- package/out/diagram/context-map-diagram-generator.js.map +1 -0
- package/out/diagram/context-map-layout-configurator.d.ts +15 -0
- package/out/diagram/context-map-layout-configurator.js +39 -0
- package/out/diagram/context-map-layout-configurator.js.map +1 -0
- package/out/diagram/elk-layout-factory.d.ts +43 -0
- package/out/diagram/elk-layout-factory.js +64 -0
- package/out/diagram/elk-layout-factory.js.map +1 -0
- package/out/domain-lang-module.d.ts +7 -0
- package/out/domain-lang-module.js +11 -2
- package/out/domain-lang-module.js.map +1 -1
- package/out/index.d.ts +3 -0
- package/out/index.js +4 -0
- package/out/index.js.map +1 -1
- package/out/lsp/domain-lang-code-lens-provider.d.ts +8 -0
- package/out/lsp/domain-lang-code-lens-provider.js +48 -0
- package/out/lsp/domain-lang-code-lens-provider.js.map +1 -0
- package/out/lsp/domain-lang-document-symbol-provider.js +5 -5
- package/out/lsp/domain-lang-document-symbol-provider.js.map +1 -1
- package/out/lsp/tool-handlers.js +63 -57
- package/out/lsp/tool-handlers.js.map +1 -1
- package/package.json +5 -2
- package/src/diagram/context-map-diagram-generator.ts +451 -0
- package/src/diagram/context-map-layout-configurator.ts +43 -0
- package/src/diagram/elk-layout-factory.ts +83 -0
- package/src/domain-lang-module.ts +19 -2
- package/src/index.ts +5 -0
- package/src/lsp/domain-lang-code-lens-provider.ts +54 -0
- package/src/lsp/domain-lang-document-symbol-provider.ts +5 -5
- package/src/lsp/tool-handlers.ts +61 -47
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import type { SModelRoot } from 'sprotty-protocol';
|
|
2
|
+
import { LangiumDiagramGenerator, type GeneratorContext } from 'langium-sprotty';
|
|
3
|
+
/**
|
|
4
|
+
* Generates context map diagrams in the **DDD community notation** style.
|
|
5
|
+
*
|
|
6
|
+
* Bounded contexts are rendered as ellipses. Relationships are rendered as edges
|
|
7
|
+
* with U/D (upstream/downstream) annotations and integration pattern labels at
|
|
8
|
+
* each end, matching the notation used in Eric Evans' "Domain-Driven Design" and
|
|
9
|
+
* Vaughn Vernon's "Implementing Domain-Driven Design".
|
|
10
|
+
*
|
|
11
|
+
* Edge label convention:
|
|
12
|
+
* - Position 0.1 (near source): `U [OHS, PL]` or `D [ACL]`
|
|
13
|
+
* - Position 0.9 (near target): `D [CF]` or `U [OHS]`
|
|
14
|
+
* - Position 0.5 (center): relationship type (e.g., "Customer/Supplier")
|
|
15
|
+
*/
|
|
16
|
+
export declare class DomainLangContextMapDiagramGenerator extends LangiumDiagramGenerator {
|
|
17
|
+
protected generateRoot(args: GeneratorContext): SModelRoot;
|
|
18
|
+
/**
|
|
19
|
+
* Creates an edge with DDD community notation labels.
|
|
20
|
+
*
|
|
21
|
+
* For `->`: left = Upstream (U), right = Downstream (D)
|
|
22
|
+
* For `<-`: left = Downstream (D), right = Upstream (U)
|
|
23
|
+
* For `<->`: Partnership (bidirectional)
|
|
24
|
+
* For `><`: Separate Ways
|
|
25
|
+
*
|
|
26
|
+
* U/D labels are rendered as DDD notation badges with optional
|
|
27
|
+
* pattern boxes (e.g., `U [OHS, PL]`).
|
|
28
|
+
*/
|
|
29
|
+
private createRelationshipEdge;
|
|
30
|
+
/**
|
|
31
|
+
* Adds a U/D badge label at the source or target end of an edge.
|
|
32
|
+
*
|
|
33
|
+
* Patterns are normalised to their short abbreviations (e.g. `OpenHostService` →
|
|
34
|
+
* `OHS`) and `BBoM`/`BigBallOfMud` is excluded — BBoM is surfaced visually as a
|
|
35
|
+
* cloud node shape rather than a text annotation.
|
|
36
|
+
*
|
|
37
|
+
* Badge text format: `ROLE|PATTERNS` (e.g. `U|OHS, PL` or `D|ACL`).
|
|
38
|
+
* The webview `UDBadgeLabelView` renders this as a bordered box.
|
|
39
|
+
*/
|
|
40
|
+
private addUDBadge;
|
|
41
|
+
/**
|
|
42
|
+
* Formats the relationship type for the center edge label.
|
|
43
|
+
*
|
|
44
|
+
* Maps DomainLang keywords to DDD community notation display names:
|
|
45
|
+
* CustomerSupplier → Customer/Supplier
|
|
46
|
+
* SharedKernel → Shared Kernel
|
|
47
|
+
* UpstreamDownstream → Upstream/Downstream
|
|
48
|
+
* Partnership → Partnership
|
|
49
|
+
*
|
|
50
|
+
* For `<->` without explicit type, defaults to "Partnership".
|
|
51
|
+
* For `><`, defaults to "Separate Ways".
|
|
52
|
+
*/
|
|
53
|
+
private formatRelationshipType;
|
|
54
|
+
private displayRelationshipType;
|
|
55
|
+
private collectContextMapNodes;
|
|
56
|
+
private ensureNodeForContextMapItem;
|
|
57
|
+
private createNode;
|
|
58
|
+
private createNodeLabel;
|
|
59
|
+
private ensureNode;
|
|
60
|
+
private ensureUnresolvedNode;
|
|
61
|
+
private getNodeKey;
|
|
62
|
+
private getSelection;
|
|
63
|
+
private getStringOption;
|
|
64
|
+
private selectContextMap;
|
|
65
|
+
}
|
|
@@ -0,0 +1,356 @@
|
|
|
1
|
+
import { LangiumDiagramGenerator } from 'langium-sprotty';
|
|
2
|
+
import { fromDocument } from '../sdk/query.js';
|
|
3
|
+
/** Ellipse sizing for bounded context nodes — sized for long names like "CustomerManagementContext" */
|
|
4
|
+
const NODE_WIDTH = 280;
|
|
5
|
+
const NODE_HEIGHT = 100;
|
|
6
|
+
/**
|
|
7
|
+
* Maps long-form DomainLang integration pattern keywords to their standard
|
|
8
|
+
* DDD abbreviations for display in U/D badges.
|
|
9
|
+
*/
|
|
10
|
+
const PATTERN_ABBREVIATIONS = {
|
|
11
|
+
OpenHostService: 'OHS',
|
|
12
|
+
PublishedLanguage: 'PL',
|
|
13
|
+
AntiCorruptionLayer: 'ACL',
|
|
14
|
+
Conformist: 'CF',
|
|
15
|
+
Partnership: 'P',
|
|
16
|
+
SharedKernel: 'SK',
|
|
17
|
+
BigBallOfMud: 'BBoM',
|
|
18
|
+
};
|
|
19
|
+
/**
|
|
20
|
+
* Returns the abbreviated form of an integration pattern keyword.
|
|
21
|
+
*
|
|
22
|
+
* Short forms (e.g. `OHS`, `ACL`) are returned unchanged. Long forms (e.g.
|
|
23
|
+
* `OpenHostService`, `AntiCorruptionLayer`) are mapped to their abbreviation.
|
|
24
|
+
*/
|
|
25
|
+
function normalizePattern(pattern) {
|
|
26
|
+
return PATTERN_ABBREVIATIONS[pattern] ?? pattern;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Returns `true` when the pattern identifies a Big Ball of Mud participant.
|
|
30
|
+
*
|
|
31
|
+
* BBoM is surfaced as a cloud node shape on the bounded context itself, not as
|
|
32
|
+
* a text annotation in the edge badge, so it should be excluded from badge text.
|
|
33
|
+
*/
|
|
34
|
+
function isBBoMPattern(pattern) {
|
|
35
|
+
return pattern === 'BBoM' || pattern === 'BigBallOfMud';
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Generates context map diagrams in the **DDD community notation** style.
|
|
39
|
+
*
|
|
40
|
+
* Bounded contexts are rendered as ellipses. Relationships are rendered as edges
|
|
41
|
+
* with U/D (upstream/downstream) annotations and integration pattern labels at
|
|
42
|
+
* each end, matching the notation used in Eric Evans' "Domain-Driven Design" and
|
|
43
|
+
* Vaughn Vernon's "Implementing Domain-Driven Design".
|
|
44
|
+
*
|
|
45
|
+
* Edge label convention:
|
|
46
|
+
* - Position 0.1 (near source): `U [OHS, PL]` or `D [ACL]`
|
|
47
|
+
* - Position 0.9 (near target): `D [CF]` or `U [OHS]`
|
|
48
|
+
* - Position 0.5 (center): relationship type (e.g., "Customer/Supplier")
|
|
49
|
+
*/
|
|
50
|
+
export class DomainLangContextMapDiagramGenerator extends LangiumDiagramGenerator {
|
|
51
|
+
generateRoot(args) {
|
|
52
|
+
const document = args.document;
|
|
53
|
+
const query = fromDocument(document);
|
|
54
|
+
const selection = this.getSelection(args);
|
|
55
|
+
const contextMaps = query.contextMaps().toArray();
|
|
56
|
+
const selectedMap = this.selectContextMap(contextMaps, query, selection);
|
|
57
|
+
if (!selectedMap) {
|
|
58
|
+
return {
|
|
59
|
+
type: 'graph',
|
|
60
|
+
id: args.idCache.uniqueId('context-map:empty'),
|
|
61
|
+
children: [],
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
// Fetch relationships first so the BBoM pre-pass can identify which BCs
|
|
65
|
+
// need the cloud node shape before any nodes are created.
|
|
66
|
+
const relationships = query.relationships()
|
|
67
|
+
.where((relationship) => relationship.source === 'ContextMap' && relationship.astNode.$container === selectedMap)
|
|
68
|
+
.toArray();
|
|
69
|
+
// BBoM pre-pass: collect the node keys of every bounded context that
|
|
70
|
+
// appears on a side annotated with the BigBallOfMud pattern. These get
|
|
71
|
+
// the `node:bbom` Sprotty type so the webview renders them as clouds.
|
|
72
|
+
const bboMNodeKeys = new Set();
|
|
73
|
+
for (const rel of relationships) {
|
|
74
|
+
if (rel.leftPatterns.some(isBBoMPattern)) {
|
|
75
|
+
bboMNodeKeys.add(this.getNodeKey(query, rel.left));
|
|
76
|
+
}
|
|
77
|
+
if (rel.rightPatterns.some(isBBoMPattern)) {
|
|
78
|
+
bboMNodeKeys.add(this.getNodeKey(query, rel.right));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
const nodeMap = new Map();
|
|
82
|
+
this.collectContextMapNodes(selectedMap, query, nodeMap, bboMNodeKeys, args);
|
|
83
|
+
for (const relationship of relationships) {
|
|
84
|
+
this.ensureNode(nodeMap, query, relationship.left, bboMNodeKeys, args);
|
|
85
|
+
this.ensureNode(nodeMap, query, relationship.right, bboMNodeKeys, args);
|
|
86
|
+
}
|
|
87
|
+
const edges = relationships.flatMap((relationship) => {
|
|
88
|
+
const leftKey = this.getNodeKey(query, relationship.left);
|
|
89
|
+
const rightKey = this.getNodeKey(query, relationship.right);
|
|
90
|
+
const leftNode = nodeMap.get(leftKey);
|
|
91
|
+
const rightNode = nodeMap.get(rightKey);
|
|
92
|
+
if (!leftNode || !rightNode) {
|
|
93
|
+
return [];
|
|
94
|
+
}
|
|
95
|
+
return this.createRelationshipEdge({
|
|
96
|
+
leftNode,
|
|
97
|
+
rightNode,
|
|
98
|
+
arrow: relationship.arrow,
|
|
99
|
+
leftPatterns: relationship.leftPatterns,
|
|
100
|
+
rightPatterns: relationship.rightPatterns,
|
|
101
|
+
type: relationship.type,
|
|
102
|
+
astNode: relationship.astNode,
|
|
103
|
+
}, args);
|
|
104
|
+
});
|
|
105
|
+
return {
|
|
106
|
+
type: 'graph',
|
|
107
|
+
id: args.idCache.uniqueId(`context-map:${selectedMap.name}`, selectedMap),
|
|
108
|
+
children: [...nodeMap.values(), ...edges],
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
// ── Relationship edges (DDD community notation) ──
|
|
112
|
+
/**
|
|
113
|
+
* Creates an edge with DDD community notation labels.
|
|
114
|
+
*
|
|
115
|
+
* For `->`: left = Upstream (U), right = Downstream (D)
|
|
116
|
+
* For `<-`: left = Downstream (D), right = Upstream (U)
|
|
117
|
+
* For `<->`: Partnership (bidirectional)
|
|
118
|
+
* For `><`: Separate Ways
|
|
119
|
+
*
|
|
120
|
+
* U/D labels are rendered as DDD notation badges with optional
|
|
121
|
+
* pattern boxes (e.g., `U [OHS, PL]`).
|
|
122
|
+
*/
|
|
123
|
+
createRelationshipEdge(params, args) {
|
|
124
|
+
const { leftNode, rightNode, arrow, leftPatterns, rightPatterns, type, astNode } = params;
|
|
125
|
+
// Determine source/target based on arrow direction
|
|
126
|
+
const sourceId = arrow === '<-' ? rightNode.id : leftNode.id;
|
|
127
|
+
const targetId = arrow === '<-' ? leftNode.id : rightNode.id;
|
|
128
|
+
const edgeId = args.idCache.uniqueId(`edge:${sourceId}:${targetId}`, astNode);
|
|
129
|
+
const children = [];
|
|
130
|
+
if (arrow === '<->') {
|
|
131
|
+
// Partnership / bidirectional — no U/D roles
|
|
132
|
+
this.addUDBadge(children, edgeId, 'source', leftPatterns, undefined, args);
|
|
133
|
+
this.addUDBadge(children, edgeId, 'target', rightPatterns, undefined, args);
|
|
134
|
+
}
|
|
135
|
+
else if (arrow === '><') {
|
|
136
|
+
// Separate Ways — no U/D, no patterns
|
|
137
|
+
}
|
|
138
|
+
else {
|
|
139
|
+
// Unidirectional: -> or <-
|
|
140
|
+
const sourcePatterns = arrow === '<-' ? rightPatterns : leftPatterns;
|
|
141
|
+
const targetPatterns = arrow === '<-' ? leftPatterns : rightPatterns;
|
|
142
|
+
this.addUDBadge(children, edgeId, 'source', sourcePatterns, 'U', args);
|
|
143
|
+
this.addUDBadge(children, edgeId, 'target', targetPatterns, 'D', args);
|
|
144
|
+
}
|
|
145
|
+
// Center label: relationship type
|
|
146
|
+
const centerLabel = this.formatRelationshipType(type, arrow);
|
|
147
|
+
if (centerLabel) {
|
|
148
|
+
children.push({
|
|
149
|
+
type: 'label:edge',
|
|
150
|
+
id: args.idCache.uniqueId(`${edgeId}:type`),
|
|
151
|
+
text: centerLabel,
|
|
152
|
+
edgePlacement: {
|
|
153
|
+
side: 'on',
|
|
154
|
+
position: 0.5,
|
|
155
|
+
rotate: false,
|
|
156
|
+
offset: 10,
|
|
157
|
+
},
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
let edgeCssClasses;
|
|
161
|
+
if (arrow === '><') {
|
|
162
|
+
edgeCssClasses = ['separate-ways'];
|
|
163
|
+
}
|
|
164
|
+
else if (arrow === '<->') {
|
|
165
|
+
edgeCssClasses = ['partnership'];
|
|
166
|
+
}
|
|
167
|
+
const edge = {
|
|
168
|
+
type: 'edge',
|
|
169
|
+
id: edgeId,
|
|
170
|
+
sourceId,
|
|
171
|
+
targetId,
|
|
172
|
+
cssClasses: edgeCssClasses,
|
|
173
|
+
children: children.length > 0 ? children : undefined,
|
|
174
|
+
};
|
|
175
|
+
this.traceProvider.trace(edge, astNode);
|
|
176
|
+
return [edge];
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
* Adds a U/D badge label at the source or target end of an edge.
|
|
180
|
+
*
|
|
181
|
+
* Patterns are normalised to their short abbreviations (e.g. `OpenHostService` →
|
|
182
|
+
* `OHS`) and `BBoM`/`BigBallOfMud` is excluded — BBoM is surfaced visually as a
|
|
183
|
+
* cloud node shape rather than a text annotation.
|
|
184
|
+
*
|
|
185
|
+
* Badge text format: `ROLE|PATTERNS` (e.g. `U|OHS, PL` or `D|ACL`).
|
|
186
|
+
* The webview `UDBadgeLabelView` renders this as a bordered box.
|
|
187
|
+
*/
|
|
188
|
+
addUDBadge(children, edgeId, placement, patterns, role, args) {
|
|
189
|
+
// Normalise pattern names and strip BBoM (shown on node, not in badge)
|
|
190
|
+
const badgePatterns = patterns
|
|
191
|
+
.filter((p) => !isBBoMPattern(p))
|
|
192
|
+
.map(normalizePattern);
|
|
193
|
+
if (!role && badgePatterns.length === 0) {
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
// Encode as ROLE|PATTERNS for UDBadgeLabelView parsing
|
|
197
|
+
const rolePart = role ?? '';
|
|
198
|
+
const patternPart = badgePatterns.length > 0 ? badgePatterns.join(', ') : '';
|
|
199
|
+
const badgeText = `${rolePart}|${patternPart}`;
|
|
200
|
+
children.push({
|
|
201
|
+
type: 'label:ud-badge',
|
|
202
|
+
id: args.idCache.uniqueId(`${edgeId}:${placement}`),
|
|
203
|
+
text: badgeText,
|
|
204
|
+
edgePlacement: {
|
|
205
|
+
side: 'on',
|
|
206
|
+
position: placement === 'source' ? 0.1 : 0.9,
|
|
207
|
+
rotate: false,
|
|
208
|
+
offset: 0,
|
|
209
|
+
},
|
|
210
|
+
});
|
|
211
|
+
}
|
|
212
|
+
/**
|
|
213
|
+
* Formats the relationship type for the center edge label.
|
|
214
|
+
*
|
|
215
|
+
* Maps DomainLang keywords to DDD community notation display names:
|
|
216
|
+
* CustomerSupplier → Customer/Supplier
|
|
217
|
+
* SharedKernel → Shared Kernel
|
|
218
|
+
* UpstreamDownstream → Upstream/Downstream
|
|
219
|
+
* Partnership → Partnership
|
|
220
|
+
*
|
|
221
|
+
* For `<->` without explicit type, defaults to "Partnership".
|
|
222
|
+
* For `><`, defaults to "Separate Ways".
|
|
223
|
+
*/
|
|
224
|
+
formatRelationshipType(type, arrow) {
|
|
225
|
+
if (type) {
|
|
226
|
+
return this.displayRelationshipType(type);
|
|
227
|
+
}
|
|
228
|
+
if (arrow === '<->') {
|
|
229
|
+
return 'Partnership';
|
|
230
|
+
}
|
|
231
|
+
if (arrow === '><') {
|
|
232
|
+
return 'Separate Ways';
|
|
233
|
+
}
|
|
234
|
+
return undefined;
|
|
235
|
+
}
|
|
236
|
+
displayRelationshipType(type) {
|
|
237
|
+
switch (type) {
|
|
238
|
+
case 'CustomerSupplier': return 'Customer/Supplier';
|
|
239
|
+
case 'SharedKernel': return 'Shared Kernel';
|
|
240
|
+
case 'UpstreamDownstream': return 'Upstream/Downstream';
|
|
241
|
+
default: return type;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
// ── Node generation ──
|
|
245
|
+
collectContextMapNodes(selectedMap, query, nodeMap, bboMNodeKeys, args) {
|
|
246
|
+
for (const boundedContextRef of selectedMap.boundedContexts) {
|
|
247
|
+
for (const item of boundedContextRef.items) {
|
|
248
|
+
this.ensureNodeForContextMapItem(item, query, nodeMap, bboMNodeKeys, args);
|
|
249
|
+
}
|
|
250
|
+
if (boundedContextRef.items.length === 0 && boundedContextRef.$refText) {
|
|
251
|
+
this.ensureUnresolvedNode(nodeMap, boundedContextRef.$refText, args);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
}
|
|
255
|
+
ensureNodeForContextMapItem(item, query, nodeMap, bboMNodeKeys, args) {
|
|
256
|
+
const boundedContext = item.ref;
|
|
257
|
+
if (!boundedContext) {
|
|
258
|
+
if (item.$refText) {
|
|
259
|
+
this.ensureUnresolvedNode(nodeMap, item.$refText, args);
|
|
260
|
+
}
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
263
|
+
const nodeKey = this.getNodeKey(query, boundedContext);
|
|
264
|
+
if (nodeMap.has(nodeKey)) {
|
|
265
|
+
return;
|
|
266
|
+
}
|
|
267
|
+
const nodeId = args.idCache.uniqueId(`node:${nodeKey}`, boundedContext);
|
|
268
|
+
const node = this.createNode(nodeId, boundedContext.name, bboMNodeKeys.has(nodeKey));
|
|
269
|
+
this.traceProvider.trace(node, boundedContext);
|
|
270
|
+
nodeMap.set(nodeKey, node);
|
|
271
|
+
}
|
|
272
|
+
createNode(id, label, isBBoM = false) {
|
|
273
|
+
return {
|
|
274
|
+
type: isBBoM ? 'node:bbom' : 'node',
|
|
275
|
+
id,
|
|
276
|
+
position: { x: 0, y: 0 },
|
|
277
|
+
size: {
|
|
278
|
+
width: NODE_WIDTH,
|
|
279
|
+
height: NODE_HEIGHT,
|
|
280
|
+
},
|
|
281
|
+
layout: 'vbox',
|
|
282
|
+
layoutOptions: {
|
|
283
|
+
hAlign: 'center',
|
|
284
|
+
vAlign: 'center',
|
|
285
|
+
resizeContainer: false,
|
|
286
|
+
paddingTop: 10,
|
|
287
|
+
paddingBottom: 10,
|
|
288
|
+
paddingLeft: 20,
|
|
289
|
+
paddingRight: 20,
|
|
290
|
+
},
|
|
291
|
+
children: [this.createNodeLabel(id, label)],
|
|
292
|
+
};
|
|
293
|
+
}
|
|
294
|
+
createNodeLabel(nodeId, label) {
|
|
295
|
+
return {
|
|
296
|
+
type: 'label',
|
|
297
|
+
id: `${nodeId}:label`,
|
|
298
|
+
text: label,
|
|
299
|
+
};
|
|
300
|
+
}
|
|
301
|
+
ensureNode(nodeMap, query, boundedContext, bboMNodeKeys, args) {
|
|
302
|
+
const nodeKey = this.getNodeKey(query, boundedContext);
|
|
303
|
+
if (nodeMap.has(nodeKey)) {
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
const nodeId = args.idCache.uniqueId(`node:${nodeKey}`, boundedContext);
|
|
307
|
+
const node = this.createNode(nodeId, boundedContext.name, bboMNodeKeys.has(nodeKey));
|
|
308
|
+
this.traceProvider.trace(node, boundedContext);
|
|
309
|
+
nodeMap.set(nodeKey, node);
|
|
310
|
+
}
|
|
311
|
+
ensureUnresolvedNode(nodeMap, label, args) {
|
|
312
|
+
const key = `unresolved:${label}`;
|
|
313
|
+
if (nodeMap.has(key)) {
|
|
314
|
+
return;
|
|
315
|
+
}
|
|
316
|
+
const nodeId = args.idCache.uniqueId(`node:${key}`);
|
|
317
|
+
nodeMap.set(key, this.createNode(nodeId, label));
|
|
318
|
+
}
|
|
319
|
+
getNodeKey(query, boundedContext) {
|
|
320
|
+
const fqn = query.fqn(boundedContext);
|
|
321
|
+
return fqn ?? boundedContext.name;
|
|
322
|
+
}
|
|
323
|
+
// ── Selection helpers ──
|
|
324
|
+
getSelection(args) {
|
|
325
|
+
const options = args.options;
|
|
326
|
+
if (typeof options !== 'object' || options === null) {
|
|
327
|
+
return {};
|
|
328
|
+
}
|
|
329
|
+
const selectedContextMapFqn = this.getStringOption(options, 'selectedContextMapFqn');
|
|
330
|
+
const selectedContextMapName = this.getStringOption(options, 'selectedContextMapName');
|
|
331
|
+
return {
|
|
332
|
+
selectedContextMapFqn,
|
|
333
|
+
selectedContextMapName,
|
|
334
|
+
};
|
|
335
|
+
}
|
|
336
|
+
getStringOption(options, key) {
|
|
337
|
+
const value = Reflect.get(options, key);
|
|
338
|
+
return typeof value === 'string' && value.trim().length > 0 ? value.trim() : undefined;
|
|
339
|
+
}
|
|
340
|
+
selectContextMap(contextMaps, query, selection) {
|
|
341
|
+
if (selection.selectedContextMapFqn) {
|
|
342
|
+
const byFqn = contextMaps.find((contextMap) => query.fqn(contextMap) === selection.selectedContextMapFqn);
|
|
343
|
+
if (byFqn) {
|
|
344
|
+
return byFqn;
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
if (selection.selectedContextMapName) {
|
|
348
|
+
const byName = contextMaps.find((contextMap) => contextMap.name === selection.selectedContextMapName);
|
|
349
|
+
if (byName) {
|
|
350
|
+
return byName;
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
return contextMaps[0];
|
|
354
|
+
}
|
|
355
|
+
}
|
|
356
|
+
//# sourceMappingURL=context-map-diagram-generator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-map-diagram-generator.js","sourceRoot":"","sources":["../../src/diagram/context-map-diagram-generator.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,uBAAuB,EAAyB,MAAM,iBAAiB,CAAC;AACjF,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAI/C,uGAAuG;AACvG,MAAM,UAAU,GAAG,GAAG,CAAC;AACvB,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB;;;GAGG;AACH,MAAM,qBAAqB,GAAqC;IAC5D,eAAe,EAAE,KAAK;IACtB,iBAAiB,EAAE,IAAI;IACvB,mBAAmB,EAAE,KAAK;IAC1B,UAAU,EAAE,IAAI;IAChB,WAAW,EAAE,GAAG;IAChB,YAAY,EAAE,IAAI;IAClB,YAAY,EAAE,MAAM;CACvB,CAAC;AAEF;;;;;GAKG;AACH,SAAS,gBAAgB,CAAC,OAAe;IACrC,OAAO,qBAAqB,CAAC,OAAO,CAAC,IAAI,OAAO,CAAC;AACrD,CAAC;AAED;;;;;GAKG;AACH,SAAS,aAAa,CAAC,OAAe;IAClC,OAAO,OAAO,KAAK,MAAM,IAAI,OAAO,KAAK,cAAc,CAAC;AAC5D,CAAC;AAiBD;;;;;;;;;;;;GAYG;AACH,MAAM,OAAO,oCAAqC,SAAQ,uBAAuB;IAC1D,YAAY,CAAC,IAAsB;QAClD,MAAM,QAAQ,GAAG,IAAI,CAAC,QAAkC,CAAC;QACzD,MAAM,KAAK,GAAG,YAAY,CAAC,QAAQ,CAAC,CAAC;QACrC,MAAM,SAAS,GAAG,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC;QAC1C,MAAM,WAAW,GAAG,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;QAElD,MAAM,WAAW,GAAG,IAAI,C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,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,UAAU,CAAC,IAAI,KAAK,SAAS,CAAC,sBAAsB,CAAC,CAAC;YACtG,IAAI,MAAM,EAAE,CAAC;gBACT,OAAO,MAAM,CAAC;YAClB,CAAC;QACL,CAAC;QAED,OAAO,WAAW,CAAC,CAAC,CAAC,CAAC;IAC1B,CAAC;CACJ"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { LayoutOptions } from 'elkjs/lib/elk-api.js';
|
|
2
|
+
import { DefaultLayoutConfigurator } from 'sprotty-elk/lib/elk-layout.js';
|
|
3
|
+
import type { SGraph, SNode, SModelIndex, SEdge } from 'sprotty-protocol';
|
|
4
|
+
/**
|
|
5
|
+
* ELK layout configurator for DomainLang context map diagrams.
|
|
6
|
+
*
|
|
7
|
+
* Uses the `layered` algorithm with **DOWN** direction (top-to-bottom) so
|
|
8
|
+
* upstream contexts appear above downstream contexts, matching the conventional
|
|
9
|
+
* DDD Context Map layout direction.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ContextMapLayoutConfigurator extends DefaultLayoutConfigurator {
|
|
12
|
+
protected graphOptions(_graph: SGraph, _index: SModelIndex): LayoutOptions;
|
|
13
|
+
protected nodeOptions(_node: SNode, _index: SModelIndex): LayoutOptions;
|
|
14
|
+
protected edgeOptions(_edge: SEdge, _index: SModelIndex): LayoutOptions;
|
|
15
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { DefaultLayoutConfigurator } from 'sprotty-elk/lib/elk-layout.js';
|
|
2
|
+
/**
|
|
3
|
+
* ELK layout configurator for DomainLang context map diagrams.
|
|
4
|
+
*
|
|
5
|
+
* Uses the `layered` algorithm with **DOWN** direction (top-to-bottom) so
|
|
6
|
+
* upstream contexts appear above downstream contexts, matching the conventional
|
|
7
|
+
* DDD Context Map layout direction.
|
|
8
|
+
*/
|
|
9
|
+
export class ContextMapLayoutConfigurator extends DefaultLayoutConfigurator {
|
|
10
|
+
graphOptions(_graph, _index) {
|
|
11
|
+
return {
|
|
12
|
+
'elk.algorithm': 'layered',
|
|
13
|
+
'elk.direction': 'DOWN',
|
|
14
|
+
'elk.layered.nodePlacement.strategy': 'BRANDES_KOEPF',
|
|
15
|
+
'elk.spacing.nodeNode': '100',
|
|
16
|
+
'elk.layered.spacing.nodeNodeBetweenLayers': '140',
|
|
17
|
+
'elk.spacing.edgeNode': '60',
|
|
18
|
+
'elk.spacing.edgeEdge': '40',
|
|
19
|
+
// Edge routing mode is irrelevant — the webview SmoothBezierEdgeView
|
|
20
|
+
// ignores ELK routing points and computes dynamic bezier curves
|
|
21
|
+
// anchored directly to node ellipses with obstacle avoidance.
|
|
22
|
+
'elk.edgeRouting': 'POLYLINE',
|
|
23
|
+
'elk.layered.mergeEdges': 'false',
|
|
24
|
+
'elk.layered.crossingMinimization.strategy': 'LAYER_SWEEP',
|
|
25
|
+
'elk.layered.thoroughness': '7',
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
nodeOptions(_node, _index) {
|
|
29
|
+
return {
|
|
30
|
+
'elk.layered.nodePlacement.bk.fixedAlignment': 'BALANCED',
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
edgeOptions(_edge, _index) {
|
|
34
|
+
return {
|
|
35
|
+
'elk.layered.priority.direction': '1',
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=context-map-layout-configurator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context-map-layout-configurator.js","sourceRoot":"","sources":["../../src/diagram/context-map-layout-configurator.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,yBAAyB,EAAE,MAAM,+BAA+B,CAAC;AAG1E;;;;;;GAMG;AACH,MAAM,OAAO,4BAA6B,SAAQ,yBAAyB;IACpD,YAAY,CAAC,MAAc,EAAE,MAAmB;QAC/D,OAAO;YACH,eAAe,EAAE,SAAS;YAC1B,eAAe,EAAE,MAAM;YACvB,oCAAoC,EAAE,eAAe;YACrD,sBAAsB,EAAE,KAAK;YAC7B,2CAA2C,EAAE,KAAK;YAClD,sBAAsB,EAAE,IAAI;YAC5B,sBAAsB,EAAE,IAAI;YAC5B,qEAAqE;YACrE,gEAAgE;YAChE,8DAA8D;YAC9D,iBAAiB,EAAE,UAAU;YAC7B,wBAAwB,EAAE,OAAO;YACjC,2CAA2C,EAAE,aAAa;YAC1D,0BAA0B,EAAE,GAAG;SAClC,CAAC;IACN,CAAC;IAEkB,WAAW,CAAC,KAAY,EAAE,MAAmB;QAC5D,OAAO;YACH,6CAA6C,EAAE,UAAU;SAC5D,CAAC;IACN,CAAC;IAEkB,WAAW,CAAC,KAAY,EAAE,MAAmB;QAC5D,OAAO;YACH,gCAAgC,EAAE,GAAG;SACxC,CAAC;IACN,CAAC;CACJ"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { type ElkFactory, type IElementFilter, type ILayoutConfigurator } from 'sprotty-elk/lib/elk-layout.js';
|
|
2
|
+
import type { IModelLayoutEngine } from 'sprotty-protocol';
|
|
3
|
+
/**
|
|
4
|
+
* Creates an {@link ElkFactory} that produces a new bundled ELK instance
|
|
5
|
+
* pre-configured for the `layered` algorithm.
|
|
6
|
+
*
|
|
7
|
+
* Use this in Langium's DI module (`layout.ElkFactory`) or directly in the
|
|
8
|
+
* CLI when running the layout engine standalone.
|
|
9
|
+
*/
|
|
10
|
+
export declare function createElkFactory(): ElkFactory;
|
|
11
|
+
/**
|
|
12
|
+
* Creates the full set of objects required to run the ELK layout engine for
|
|
13
|
+
* DomainLang context-map diagrams.
|
|
14
|
+
*
|
|
15
|
+
* Returns the three collaborators that together constitute a complete
|
|
16
|
+
* `IModelLayoutEngine`:
|
|
17
|
+
* - `elkFactory` — produces the ELK worker instance
|
|
18
|
+
* - `elementFilter` — controls which model elements are laid out
|
|
19
|
+
* - `layoutConfigurator` — supplies algorithm-specific ELK options
|
|
20
|
+
*
|
|
21
|
+
* Callers that use Langium DI should register these individually via the
|
|
22
|
+
* `layout` service group. Callers that operate outside of DI (e.g. the CLI)
|
|
23
|
+
* can call {@link createElkLayoutEngine} for a fully assembled engine.
|
|
24
|
+
*/
|
|
25
|
+
export declare function createElkLayoutComponents(): {
|
|
26
|
+
elkFactory: ElkFactory;
|
|
27
|
+
elementFilter: IElementFilter;
|
|
28
|
+
layoutConfigurator: ILayoutConfigurator;
|
|
29
|
+
};
|
|
30
|
+
/**
|
|
31
|
+
* Creates a fully assembled {@link IModelLayoutEngine} for DomainLang
|
|
32
|
+
* context-map diagrams using the bundled ELK engine.
|
|
33
|
+
*
|
|
34
|
+
* Intended for use outside of Langium's DI container — for example, in the
|
|
35
|
+
* CLI when generating standalone SVG or image exports.
|
|
36
|
+
*
|
|
37
|
+
* @example
|
|
38
|
+
* ```typescript
|
|
39
|
+
* const layoutEngine = createElkLayoutEngine();
|
|
40
|
+
* const laidOutModel = await layoutEngine.layout(rootModel);
|
|
41
|
+
* ```
|
|
42
|
+
*/
|
|
43
|
+
export declare function createElkLayoutEngine(): IModelLayoutEngine;
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ELK layout engine factory for DomainLang diagrams.
|
|
3
|
+
*
|
|
4
|
+
* Encapsulates the ELK construction, factory wiring, and Sprotty-ELK layout
|
|
5
|
+
* engine instantiation so that both the VS Code extension (via the LSP server
|
|
6
|
+
* DI module) and the CLI (for standalone diagram export) can reuse the same
|
|
7
|
+
* layout logic without embedding the setup inline.
|
|
8
|
+
*
|
|
9
|
+
* @module diagram/elk-layout-factory
|
|
10
|
+
*/
|
|
11
|
+
import * as ElkBundled from 'elkjs/lib/elk.bundled.js';
|
|
12
|
+
import { DefaultElementFilter, ElkLayoutEngine, } from 'sprotty-elk/lib/elk-layout.js';
|
|
13
|
+
import { ContextMapLayoutConfigurator } from './context-map-layout-configurator.js';
|
|
14
|
+
const _elkConstructor = (ElkBundled.default
|
|
15
|
+
?? ElkBundled);
|
|
16
|
+
/**
|
|
17
|
+
* Creates an {@link ElkFactory} that produces a new bundled ELK instance
|
|
18
|
+
* pre-configured for the `layered` algorithm.
|
|
19
|
+
*
|
|
20
|
+
* Use this in Langium's DI module (`layout.ElkFactory`) or directly in the
|
|
21
|
+
* CLI when running the layout engine standalone.
|
|
22
|
+
*/
|
|
23
|
+
export function createElkFactory() {
|
|
24
|
+
return () => new _elkConstructor({ algorithms: ['layered'] });
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Creates the full set of objects required to run the ELK layout engine for
|
|
28
|
+
* DomainLang context-map diagrams.
|
|
29
|
+
*
|
|
30
|
+
* Returns the three collaborators that together constitute a complete
|
|
31
|
+
* `IModelLayoutEngine`:
|
|
32
|
+
* - `elkFactory` — produces the ELK worker instance
|
|
33
|
+
* - `elementFilter` — controls which model elements are laid out
|
|
34
|
+
* - `layoutConfigurator` — supplies algorithm-specific ELK options
|
|
35
|
+
*
|
|
36
|
+
* Callers that use Langium DI should register these individually via the
|
|
37
|
+
* `layout` service group. Callers that operate outside of DI (e.g. the CLI)
|
|
38
|
+
* can call {@link createElkLayoutEngine} for a fully assembled engine.
|
|
39
|
+
*/
|
|
40
|
+
export function createElkLayoutComponents() {
|
|
41
|
+
return {
|
|
42
|
+
elkFactory: createElkFactory(),
|
|
43
|
+
elementFilter: new DefaultElementFilter(),
|
|
44
|
+
layoutConfigurator: new ContextMapLayoutConfigurator(),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Creates a fully assembled {@link IModelLayoutEngine} for DomainLang
|
|
49
|
+
* context-map diagrams using the bundled ELK engine.
|
|
50
|
+
*
|
|
51
|
+
* Intended for use outside of Langium's DI container — for example, in the
|
|
52
|
+
* CLI when generating standalone SVG or image exports.
|
|
53
|
+
*
|
|
54
|
+
* @example
|
|
55
|
+
* ```typescript
|
|
56
|
+
* const layoutEngine = createElkLayoutEngine();
|
|
57
|
+
* const laidOutModel = await layoutEngine.layout(rootModel);
|
|
58
|
+
* ```
|
|
59
|
+
*/
|
|
60
|
+
export function createElkLayoutEngine() {
|
|
61
|
+
const { elkFactory, elementFilter, layoutConfigurator } = createElkLayoutComponents();
|
|
62
|
+
return new ElkLayoutEngine(elkFactory, elementFilter, layoutConfigurator);
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=elk-layout-factory.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"elk-layout-factory.js","sourceRoot":"","sources":["../../src/diagram/elk-layout-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AACH,OAAO,KAAK,UAAU,MAAM,0BAA0B,CAAC;AAEvD,OAAO,EACH,oBAAoB,EACpB,eAAe,GAIlB,MAAM,+BAA+B,CAAC;AAEvC,OAAO,EAAE,4BAA4B,EAAE,MAAM,sCAAsC,CAAC;AAIpF,MAAM,eAAe,GAAmB,CACnC,UAAsD,CAAC,OAAO;OAC3D,UAAwC,CAC/C,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,UAAU,gBAAgB;IAC5B,OAAO,GAAG,EAAE,CAAC,IAAI,eAAe,CAAC,EAAE,UAAU,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;AAClE,CAAC;AAED;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,yBAAyB;IAKrC,OAAO;QACH,UAAU,EAAE,gBAAgB,EAAE;QAC9B,aAAa,EAAE,IAAI,oBAAoB,EAAE;QACzC,kBAAkB,EAAE,IAAI,4BAA4B,EAAE;KACzD,CAAC;AACN,CAAC;AAED;;;;;;;;;;;;GAYG;AACH,MAAM,UAAU,qBAAqB;IACjC,MAAM,EAAE,UAAU,EAAE,aAAa,EAAE,kBAAkB,EAAE,GAAG,yBAAyB,EAAE,CAAC;IACtF,OAAO,IAAI,eAAe,CAAC,UAAU,EAAE,aAAa,EAAE,kBAAkB,CAAuB,CAAC;AACpG,CAAC"}
|
|
@@ -5,6 +5,8 @@ import { DomainLangFormatter } from './lsp/domain-lang-formatter.js';
|
|
|
5
5
|
import { DomainLangHoverProvider } from './lsp/hover/domain-lang-hover.js';
|
|
6
6
|
import { DomainLangCompletionProvider } from './lsp/domain-lang-completion.js';
|
|
7
7
|
import { DomainLangCodeActionProvider } from './lsp/domain-lang-code-actions.js';
|
|
8
|
+
import { DomainLangCodeLensProvider } from './lsp/domain-lang-code-lens-provider.js';
|
|
9
|
+
import type { IDiagramGenerator, IModelLayoutEngine } from 'sprotty-protocol';
|
|
8
10
|
import { ImportResolver } from './services/import-resolver.js';
|
|
9
11
|
import { ManifestManager } from './services/workspace-manager.js';
|
|
10
12
|
import { PackageBoundaryDetector } from './services/package-boundary-detector.js';
|
|
@@ -24,8 +26,13 @@ export type DomainLangAddedServices = {
|
|
|
24
26
|
Formatter: DomainLangFormatter;
|
|
25
27
|
HoverProvider: DomainLangHoverProvider;
|
|
26
28
|
CompletionProvider: DomainLangCompletionProvider;
|
|
29
|
+
CodeLensProvider: DomainLangCodeLensProvider;
|
|
27
30
|
CodeActionProvider: DomainLangCodeActionProvider;
|
|
28
31
|
};
|
|
32
|
+
diagram: {
|
|
33
|
+
DiagramGenerator: IDiagramGenerator;
|
|
34
|
+
ModelLayoutEngine: IModelLayoutEngine;
|
|
35
|
+
};
|
|
29
36
|
};
|
|
30
37
|
/**
|
|
31
38
|
* Union of Langium default services and your custom services - use this as constructor parameter
|