@likec4/language-server 1.15.1 → 1.17.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/contrib/likec4.tmLanguage.json +1 -1
- package/dist/browser.cjs +1 -1
- package/dist/browser.d.cts +2 -2
- package/dist/browser.d.mts +2 -2
- package/dist/browser.d.ts +2 -2
- package/dist/browser.mjs +2 -2
- package/dist/index.cjs +35 -5
- package/dist/index.d.cts +17 -4
- package/dist/index.d.mts +17 -4
- package/dist/index.d.ts +17 -4
- package/dist/index.mjs +34 -5
- package/dist/model-graph/index.cjs +1 -1
- package/dist/model-graph/index.d.cts +4 -2
- package/dist/model-graph/index.d.mts +4 -2
- package/dist/model-graph/index.d.ts +4 -2
- package/dist/model-graph/index.mjs +1 -1
- package/dist/shared/{language-server.BuChFlda.mjs → language-server.B8qSDsWW.mjs} +211 -96
- package/dist/shared/language-server.BGGRJRnr.d.mts +1338 -0
- package/dist/shared/{language-server.BT4WTbFI.mjs → language-server.BXFhlTPo.mjs} +139 -76
- package/dist/shared/{language-server.DfMwkd2l.d.mts → language-server.BgDKnNok.d.mts} +45 -11
- package/dist/shared/language-server.Bmpq16Gw.d.ts +1338 -0
- package/dist/shared/language-server.C1ZfM22X.d.cts +1338 -0
- package/dist/shared/{language-server.U2piOAVt.d.cts → language-server.DJo88TnT.d.cts} +45 -11
- package/dist/shared/{language-server.DfjkvknB.cjs → language-server.DZRuJVSg.cjs} +209 -94
- package/dist/shared/{language-server.B8s2wfT_.cjs → language-server.N8HLDQqz.cjs} +137 -74
- package/dist/shared/{language-server.j-ShR6as.d.ts → language-server.PEjk7U9s.d.ts} +45 -11
- package/package.json +7 -7
- package/src/LikeC4FileSystem.ts +36 -0
- package/src/Rpc.ts +2 -2
- package/src/ast.ts +11 -3
- package/src/generated/ast.ts +112 -11
- package/src/generated/grammar.ts +1 -1
- package/src/index.ts +3 -3
- package/src/like-c4.langium +20 -1
- package/src/lsp/SemanticTokenProvider.ts +26 -8
- package/src/model/fqn-computation.ts +6 -2
- package/src/model/model-builder.ts +25 -30
- package/src/model/model-parser.ts +91 -18
- package/src/model-graph/LikeC4ModelGraph.ts +22 -11
- package/src/model-graph/compute-view/__test__/fixture.ts +69 -19
- package/src/model-graph/compute-view/compute.ts +85 -73
- package/src/model-graph/dynamic-view/compute.ts +12 -2
- package/src/model-graph/utils/applyCustomElementProperties.ts +1 -3
- package/src/model-graph/utils/applyViewRuleStyles.ts +0 -4
- package/src/references/scope-computation.ts +10 -0
- package/src/validation/index.ts +3 -0
- package/src/validation/specification.ts +21 -0
- package/src/view-utils/index.ts +0 -1
- package/src/view-utils/resolve-global-rules.ts +66 -50
|
@@ -1,8 +1,54 @@
|
|
|
1
|
-
import { Expr, whereOperatorAsPredicate, parentFqn, nonexhaustive, ComputedNode, isViewRuleGroup, isViewRulePredicate, isViewRuleStyle, nonNullable, ElementKind, compareByFqnHierarchically, DefaultThemeColor, DefaultElementShape, compareRelations, invariant, compareNatural, hasAtLeast, isAncestor,
|
|
2
|
-
import { pipe, map, pick, mapToObj, isTruthy,
|
|
1
|
+
import { isViewRuleGlobalPredicateRef, isViewRuleGlobalStyle, Expr, whereOperatorAsPredicate, parentFqn, nonexhaustive, ComputedNode, isViewRuleGroup, isViewRulePredicate, isViewRuleStyle, nonNullable, ElementKind, compareByFqnHierarchically, DefaultThemeColor, DefaultElementShape, compareRelations, invariant, compareNatural, hasAtLeast, isAncestor, isScopedElementView, isViewRuleAutoLayout, commonAncestor, commonHead, StepEdgeId, isDynamicViewParallelSteps, isDynamicViewIncludeRule, DefaultRelationshipColor, DefaultLineStyle, DefaultArrowType, ancestorsFqn, isSameHierarchy } from '@likec4/core';
|
|
2
|
+
import { isNullish, pipe, map, pick, mapToObj, isTruthy, omitBy, isEmpty, filter, isNot, anyPass, forEach, isDefined, groupBy, prop, mapValues, piped, unique, entries, flatMap, sortBy, sort, tap, difference, allPass, concat, hasAtLeast as hasAtLeast$1, only, reduce, last, reverse, isNonNull, first, isString, isArray } from 'remeda';
|
|
3
3
|
import dagre from '@dagrejs/dagre';
|
|
4
|
+
import { logger } from '@likec4/log';
|
|
4
5
|
import objectHash from 'object-hash';
|
|
5
6
|
|
|
7
|
+
function resolveGlobalRulesInElementView(view, globals) {
|
|
8
|
+
return view.rules.reduce((acc, rule) => {
|
|
9
|
+
if (isViewRuleGlobalPredicateRef(rule)) {
|
|
10
|
+
const globalPredicates = globals.predicates[rule.predicateId];
|
|
11
|
+
if (isNullish(globalPredicates)) {
|
|
12
|
+
logger.warn(`Global predicate not found: ${rule.predicateId}`);
|
|
13
|
+
return acc;
|
|
14
|
+
}
|
|
15
|
+
return acc.concat(globalPredicates);
|
|
16
|
+
}
|
|
17
|
+
if (isViewRuleGlobalStyle(rule)) {
|
|
18
|
+
const globalStyles = globals.styles[rule.styleId];
|
|
19
|
+
if (isNullish(globalStyles)) {
|
|
20
|
+
logger.warn(`Global style not found: ${rule.styleId}`);
|
|
21
|
+
return acc;
|
|
22
|
+
}
|
|
23
|
+
return acc.concat(globalStyles);
|
|
24
|
+
}
|
|
25
|
+
acc.push(rule);
|
|
26
|
+
return acc;
|
|
27
|
+
}, []);
|
|
28
|
+
}
|
|
29
|
+
function resolveGlobalRulesInDynamicView(view, globals) {
|
|
30
|
+
return view.rules.reduce((acc, rule) => {
|
|
31
|
+
if (isViewRuleGlobalPredicateRef(rule)) {
|
|
32
|
+
const globalPredicates = globals.dynamicPredicates[rule.predicateId];
|
|
33
|
+
if (isNullish(globalPredicates)) {
|
|
34
|
+
logger.warn(`Global predicate not found: ${rule.predicateId}`);
|
|
35
|
+
return acc;
|
|
36
|
+
}
|
|
37
|
+
return acc.concat(globalPredicates);
|
|
38
|
+
}
|
|
39
|
+
if (isViewRuleGlobalStyle(rule)) {
|
|
40
|
+
const globalStyles = globals.styles[rule.styleId];
|
|
41
|
+
if (isNullish(globalStyles)) {
|
|
42
|
+
logger.warn(`Global style not found: ${rule.styleId}`);
|
|
43
|
+
return acc;
|
|
44
|
+
}
|
|
45
|
+
return acc.concat(globalStyles);
|
|
46
|
+
}
|
|
47
|
+
acc.push(rule);
|
|
48
|
+
return acc;
|
|
49
|
+
}, []);
|
|
50
|
+
}
|
|
51
|
+
|
|
6
52
|
function calcViewLayoutHash(view) {
|
|
7
53
|
const tohash = {
|
|
8
54
|
id: view.id,
|
|
@@ -179,10 +225,6 @@ function applyViewRuleStyles(_rules, nodes) {
|
|
|
179
225
|
for (const rule of rules) {
|
|
180
226
|
const predicates = [];
|
|
181
227
|
for (const target of rule.targets) {
|
|
182
|
-
if (Expr.isWildcard(target)) {
|
|
183
|
-
predicates.push(() => true);
|
|
184
|
-
break;
|
|
185
|
-
}
|
|
186
228
|
predicates.push(elementExprToPredicate(target));
|
|
187
229
|
}
|
|
188
230
|
pipe(
|
|
@@ -922,6 +964,25 @@ class ComputeCtx {
|
|
|
922
964
|
get activeGroup() {
|
|
923
965
|
return this.activeGroupStack[0] ?? this.__rootGroup;
|
|
924
966
|
}
|
|
967
|
+
get includedElements() {
|
|
968
|
+
return /* @__PURE__ */ new Set([
|
|
969
|
+
...this.explicits,
|
|
970
|
+
...this.ctxEdges.flatMap((e) => [e.source, e.target])
|
|
971
|
+
]);
|
|
972
|
+
}
|
|
973
|
+
get resolvedElements() {
|
|
974
|
+
return /* @__PURE__ */ new Set([
|
|
975
|
+
...this.explicits,
|
|
976
|
+
...this.implicits,
|
|
977
|
+
...this.ctxEdges.flatMap((e) => [e.source, e.target])
|
|
978
|
+
]);
|
|
979
|
+
}
|
|
980
|
+
get edges() {
|
|
981
|
+
return this.ctxEdges;
|
|
982
|
+
}
|
|
983
|
+
get root() {
|
|
984
|
+
return isScopedElementView(this.view) ? this.view.viewOf : null;
|
|
985
|
+
}
|
|
925
986
|
static elementView(view, graph) {
|
|
926
987
|
return new ComputeCtx(view, graph).compute();
|
|
927
988
|
}
|
|
@@ -930,9 +991,11 @@ class ComputeCtx {
|
|
|
930
991
|
const {
|
|
931
992
|
docUri: _docUri,
|
|
932
993
|
// exclude docUri
|
|
933
|
-
rules,
|
|
994
|
+
rules: _rules,
|
|
995
|
+
// exclude rules
|
|
934
996
|
...view
|
|
935
997
|
} = this.view;
|
|
998
|
+
const rules = resolveGlobalRulesInElementView(this.view, this.graph.globals);
|
|
936
999
|
const viewPredicates = rules.filter(anyPass([isViewRulePredicate, isViewRuleGroup]));
|
|
937
1000
|
if (this.root && viewPredicates.length == 0) {
|
|
938
1001
|
this.addElement(this.graph.element(this.root));
|
|
@@ -944,51 +1007,9 @@ class ComputeCtx {
|
|
|
944
1007
|
}
|
|
945
1008
|
const elements = [...this.includedElements];
|
|
946
1009
|
const nodesMap = buildComputeNodes(elements, this.groups);
|
|
947
|
-
const ancestorsOf = (node) => {
|
|
948
|
-
const ancestors = [];
|
|
949
|
-
let parent = node.parent;
|
|
950
|
-
while (parent) {
|
|
951
|
-
const parentNode = nodesMap.get(parent);
|
|
952
|
-
if (!parentNode) {
|
|
953
|
-
break;
|
|
954
|
-
}
|
|
955
|
-
ancestors.push(parentNode);
|
|
956
|
-
parent = parentNode.parent;
|
|
957
|
-
}
|
|
958
|
-
return ancestors;
|
|
959
|
-
};
|
|
960
|
-
const edgesMap = /* @__PURE__ */ new Map();
|
|
961
1010
|
const edges = this.computeEdges();
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
const source = nodesMap.get(edge.source);
|
|
965
|
-
const target = nodesMap.get(edge.target);
|
|
966
|
-
invariant(source, `Source node ${edge.source} not found`);
|
|
967
|
-
invariant(target, `Target node ${edge.target} not found`);
|
|
968
|
-
const sourceAncestors = ancestorsOf(source);
|
|
969
|
-
const targetAncestors = ancestorsOf(target);
|
|
970
|
-
const edgeParent = last(
|
|
971
|
-
commonHead(
|
|
972
|
-
reverse(sourceAncestors),
|
|
973
|
-
reverse(targetAncestors)
|
|
974
|
-
)
|
|
975
|
-
);
|
|
976
|
-
edge.parent = edgeParent?.id ?? null;
|
|
977
|
-
source.outEdges.push(edge.id);
|
|
978
|
-
target.inEdges.push(edge.id);
|
|
979
|
-
for (const sourceAncestor of sourceAncestors) {
|
|
980
|
-
if (sourceAncestor === edgeParent) {
|
|
981
|
-
break;
|
|
982
|
-
}
|
|
983
|
-
sourceAncestor.outEdges.push(edge.id);
|
|
984
|
-
}
|
|
985
|
-
for (const targetAncestor of targetAncestors) {
|
|
986
|
-
if (targetAncestor === edgeParent) {
|
|
987
|
-
break;
|
|
988
|
-
}
|
|
989
|
-
targetAncestor.inEdges.push(edge.id);
|
|
990
|
-
}
|
|
991
|
-
}
|
|
1011
|
+
const edgesMap = new Map(edges.map((edge) => [edge.id, edge]));
|
|
1012
|
+
this.linkNodesAndEdges(nodesMap, edges);
|
|
992
1013
|
let initialSort = elements.map((e) => nonNullable(nodesMap.get(e.id), `Node ${e.id} not found in nodesMap`));
|
|
993
1014
|
if (this.groups.length > 0) {
|
|
994
1015
|
initialSort = concat(
|
|
@@ -1020,7 +1041,13 @@ class ComputeCtx {
|
|
|
1020
1041
|
...autoLayoutRule?.nodeSep && { nodeSep: autoLayoutRule.nodeSep },
|
|
1021
1042
|
...autoLayoutRule?.rankSep && { rankSep: autoLayoutRule.rankSep }
|
|
1022
1043
|
},
|
|
1023
|
-
nodes: map(nodes,
|
|
1044
|
+
nodes: map(nodes, (n) => {
|
|
1045
|
+
delete n.notation;
|
|
1046
|
+
if (n.icon === "none") {
|
|
1047
|
+
delete n.icon;
|
|
1048
|
+
}
|
|
1049
|
+
return n;
|
|
1050
|
+
}),
|
|
1024
1051
|
edges: applyCustomRelationProperties(rules, nodes, sortedEdges),
|
|
1025
1052
|
...elementNotations.length > 0 && {
|
|
1026
1053
|
notation: {
|
|
@@ -1029,9 +1056,6 @@ class ComputeCtx {
|
|
|
1029
1056
|
}
|
|
1030
1057
|
});
|
|
1031
1058
|
}
|
|
1032
|
-
get root() {
|
|
1033
|
-
return isScopedElementView(this.view) ? this.view.viewOf : null;
|
|
1034
|
-
}
|
|
1035
1059
|
computeEdges() {
|
|
1036
1060
|
return this.ctxEdges.map((e) => {
|
|
1037
1061
|
invariant(hasAtLeast$1(e.relations, 1), "Edge must have at least one relation");
|
|
@@ -1124,21 +1148,36 @@ class ComputeCtx {
|
|
|
1124
1148
|
);
|
|
1125
1149
|
});
|
|
1126
1150
|
}
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1151
|
+
linkNodesAndEdges(nodesMap, edges) {
|
|
1152
|
+
for (const edge of edges) {
|
|
1153
|
+
const source = nodesMap.get(edge.source);
|
|
1154
|
+
const target = nodesMap.get(edge.target);
|
|
1155
|
+
invariant(source, `Source node ${edge.source} not found`);
|
|
1156
|
+
invariant(target, `Target node ${edge.target} not found`);
|
|
1157
|
+
const sourceAncestors = this.ancestorsOf(source, nodesMap);
|
|
1158
|
+
const targetAncestors = this.ancestorsOf(target, nodesMap);
|
|
1159
|
+
const edgeParent = last(
|
|
1160
|
+
commonHead(
|
|
1161
|
+
reverse(sourceAncestors),
|
|
1162
|
+
reverse(targetAncestors)
|
|
1163
|
+
)
|
|
1164
|
+
);
|
|
1165
|
+
edge.parent = edgeParent?.id ?? null;
|
|
1166
|
+
source.outEdges.push(edge.id);
|
|
1167
|
+
target.inEdges.push(edge.id);
|
|
1168
|
+
for (const sourceAncestor of sourceAncestors) {
|
|
1169
|
+
if (sourceAncestor === edgeParent) {
|
|
1170
|
+
break;
|
|
1171
|
+
}
|
|
1172
|
+
sourceAncestor.outEdges.push(edge.id);
|
|
1173
|
+
}
|
|
1174
|
+
for (const targetAncestor of targetAncestors) {
|
|
1175
|
+
if (targetAncestor === edgeParent) {
|
|
1176
|
+
break;
|
|
1177
|
+
}
|
|
1178
|
+
targetAncestor.inEdges.push(edge.id);
|
|
1179
|
+
}
|
|
1180
|
+
}
|
|
1142
1181
|
}
|
|
1143
1182
|
addEdges(edges) {
|
|
1144
1183
|
const added = [];
|
|
@@ -1227,9 +1266,6 @@ class ComputeCtx {
|
|
|
1227
1266
|
}),
|
|
1228
1267
|
filter(isNonNull)
|
|
1229
1268
|
);
|
|
1230
|
-
if (excludedImplicits.size === 0) {
|
|
1231
|
-
return;
|
|
1232
|
-
}
|
|
1233
1269
|
this.ctxEdges = ctxEdges;
|
|
1234
1270
|
const remaining = this.includedElements;
|
|
1235
1271
|
if (remaining.size === 0) {
|
|
@@ -1406,6 +1442,19 @@ class ComputeCtx {
|
|
|
1406
1442
|
}
|
|
1407
1443
|
nonexhaustive(expr);
|
|
1408
1444
|
}
|
|
1445
|
+
ancestorsOf(node, nodesMap) {
|
|
1446
|
+
const ancestors = [];
|
|
1447
|
+
let parent = node.parent;
|
|
1448
|
+
while (parent) {
|
|
1449
|
+
const parentNode = nodesMap.get(parent);
|
|
1450
|
+
if (!parentNode) {
|
|
1451
|
+
break;
|
|
1452
|
+
}
|
|
1453
|
+
ancestors.push(parentNode);
|
|
1454
|
+
parent = parentNode.parent;
|
|
1455
|
+
}
|
|
1456
|
+
return ancestors;
|
|
1457
|
+
}
|
|
1409
1458
|
getEdgeLabel(relation) {
|
|
1410
1459
|
const labelParts = [];
|
|
1411
1460
|
if (isTruthy(relation.title)) {
|
|
@@ -1483,7 +1532,8 @@ class DynamicViewComputeCtx {
|
|
|
1483
1532
|
const {
|
|
1484
1533
|
docUri: _docUri,
|
|
1485
1534
|
// exclude docUri
|
|
1486
|
-
rules,
|
|
1535
|
+
rules: _rules,
|
|
1536
|
+
// exclude rules
|
|
1487
1537
|
steps: viewSteps,
|
|
1488
1538
|
...view
|
|
1489
1539
|
} = this.view;
|
|
@@ -1503,6 +1553,7 @@ class DynamicViewComputeCtx {
|
|
|
1503
1553
|
}
|
|
1504
1554
|
stepNum++;
|
|
1505
1555
|
}
|
|
1556
|
+
const rules = resolveGlobalRulesInDynamicView(this.view, this.graph.globals);
|
|
1506
1557
|
for (const rule of rules) {
|
|
1507
1558
|
if (isDynamicViewIncludeRule(rule)) {
|
|
1508
1559
|
for (const expr of rule.include) {
|
|
@@ -1566,7 +1617,13 @@ class DynamicViewComputeCtx {
|
|
|
1566
1617
|
...autoLayoutRule?.nodeSep && { nodeSep: autoLayoutRule.nodeSep },
|
|
1567
1618
|
...autoLayoutRule?.rankSep && { rankSep: autoLayoutRule.rankSep }
|
|
1568
1619
|
},
|
|
1569
|
-
nodes: map(nodes,
|
|
1620
|
+
nodes: map(nodes, (n) => {
|
|
1621
|
+
delete n.notation;
|
|
1622
|
+
if (n.icon === "none") {
|
|
1623
|
+
delete n.icon;
|
|
1624
|
+
}
|
|
1625
|
+
return n;
|
|
1626
|
+
}),
|
|
1570
1627
|
edges,
|
|
1571
1628
|
...elementNotations.length > 0 && {
|
|
1572
1629
|
notation: {
|
|
@@ -1656,7 +1713,13 @@ class LikeC4ModelGraph {
|
|
|
1656
1713
|
// Relationships inside the element, among descendants
|
|
1657
1714
|
#internal = new MapRelations();
|
|
1658
1715
|
#cacheAscendingSiblings = /* @__PURE__ */ new Map();
|
|
1659
|
-
|
|
1716
|
+
globals;
|
|
1717
|
+
constructor({ elements, relations, globals }) {
|
|
1718
|
+
this.globals = globals ?? {
|
|
1719
|
+
predicates: {},
|
|
1720
|
+
dynamicPredicates: {},
|
|
1721
|
+
styles: {}
|
|
1722
|
+
};
|
|
1660
1723
|
for (const el of Object.values(elements)) {
|
|
1661
1724
|
this.addElement(el);
|
|
1662
1725
|
}
|
|
@@ -47,7 +47,7 @@ type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | '
|
|
|
47
47
|
type BorderStyleValue = 'none' | LineOptions;
|
|
48
48
|
type CustomColorId = 'element' | 'model' | ArrowType | ElementShape | LineOptions | string;
|
|
49
49
|
type CustomColorValue = string;
|
|
50
|
-
type DynamicViewRule = DynamicViewIncludePredicate | ViewRuleAutoLayout | ViewRuleStyleOrGlobalRef;
|
|
50
|
+
type DynamicViewRule = DynamicViewGlobalPredicateRef | DynamicViewIncludePredicate | ViewRuleAutoLayout | ViewRuleStyleOrGlobalRef;
|
|
51
51
|
declare const DynamicViewRule = "DynamicViewRule";
|
|
52
52
|
declare function isDynamicViewRule(item: unknown): item is DynamicViewRule;
|
|
53
53
|
type ElementExpression = ElementDescedantsExpression | ElementKindExpression | ElementRef | ElementTagExpression | ExpandElementExpression | WildcardExpression;
|
|
@@ -94,7 +94,7 @@ type ViewLayoutDirection = 'BottomTop' | 'LeftRight' | 'RightLeft' | 'TopBottom'
|
|
|
94
94
|
type ViewProperty = LinkProperty | ViewStringProperty;
|
|
95
95
|
declare const ViewProperty = "ViewProperty";
|
|
96
96
|
declare function isViewProperty(item: unknown): item is ViewProperty;
|
|
97
|
-
type ViewRule = ViewRuleAutoLayout | ViewRuleGroup | ViewRulePredicate | ViewRuleStyleOrGlobalRef;
|
|
97
|
+
type ViewRule = ViewRuleAutoLayout | ViewRuleGlobalPredicateRef | ViewRuleGroup | ViewRulePredicate | ViewRuleStyleOrGlobalRef;
|
|
98
98
|
declare const ViewRule = "ViewRule";
|
|
99
99
|
declare function isViewRule(item: unknown): item is ViewRule;
|
|
100
100
|
type ViewRulePredicate = ExcludePredicate | IncludePredicate;
|
|
@@ -179,8 +179,14 @@ interface DynamicViewBody extends AstNode {
|
|
|
179
179
|
}
|
|
180
180
|
declare const DynamicViewBody = "DynamicViewBody";
|
|
181
181
|
declare function isDynamicViewBody(item: unknown): item is DynamicViewBody;
|
|
182
|
-
interface
|
|
182
|
+
interface DynamicViewGlobalPredicateRef extends AstNode {
|
|
183
183
|
readonly $container: DynamicViewBody;
|
|
184
|
+
readonly $type: 'DynamicViewGlobalPredicateRef';
|
|
185
|
+
predicate: Reference<GlobalDynamicPredicateGroup>;
|
|
186
|
+
}
|
|
187
|
+
declare const DynamicViewGlobalPredicateRef = "DynamicViewGlobalPredicateRef";
|
|
188
|
+
interface DynamicViewIncludePredicate extends AstNode {
|
|
189
|
+
readonly $container: DynamicViewBody | GlobalDynamicPredicateGroup;
|
|
184
190
|
readonly $type: 'DynamicViewIncludePredicate';
|
|
185
191
|
predicates: DynamicViewPredicateIterator;
|
|
186
192
|
}
|
|
@@ -331,7 +337,7 @@ interface ElementViewRef extends AstNode {
|
|
|
331
337
|
}
|
|
332
338
|
declare const ElementViewRef = "ElementViewRef";
|
|
333
339
|
interface ExcludePredicate extends AstNode {
|
|
334
|
-
readonly $container: ElementViewBody | ViewRuleGroup;
|
|
340
|
+
readonly $container: ElementViewBody | GlobalPredicateGroup | ViewRuleGroup;
|
|
335
341
|
readonly $type: 'ExcludePredicate';
|
|
336
342
|
predicates: Predicates;
|
|
337
343
|
}
|
|
@@ -364,10 +370,27 @@ interface FqnElementRef extends AstNode {
|
|
|
364
370
|
parent?: FqnElementRef;
|
|
365
371
|
}
|
|
366
372
|
declare const FqnElementRef = "FqnElementRef";
|
|
373
|
+
interface GlobalDynamicPredicateGroup extends AstNode {
|
|
374
|
+
readonly $container: Globals;
|
|
375
|
+
readonly $type: 'GlobalDynamicPredicateGroup';
|
|
376
|
+
name: string;
|
|
377
|
+
predicates: Array<DynamicViewIncludePredicate>;
|
|
378
|
+
}
|
|
379
|
+
declare const GlobalDynamicPredicateGroup = "GlobalDynamicPredicateGroup";
|
|
380
|
+
declare function isGlobalDynamicPredicateGroup(item: unknown): item is GlobalDynamicPredicateGroup;
|
|
381
|
+
interface GlobalPredicateGroup extends AstNode {
|
|
382
|
+
readonly $container: Globals;
|
|
383
|
+
readonly $type: 'GlobalPredicateGroup';
|
|
384
|
+
name: string;
|
|
385
|
+
predicates: Array<ViewRulePredicate>;
|
|
386
|
+
}
|
|
387
|
+
declare const GlobalPredicateGroup = "GlobalPredicateGroup";
|
|
388
|
+
declare function isGlobalPredicateGroup(item: unknown): item is GlobalPredicateGroup;
|
|
367
389
|
interface Globals extends AstNode {
|
|
368
390
|
readonly $container: LikeC4Grammar;
|
|
369
391
|
readonly $type: 'Globals';
|
|
370
392
|
name: 'global';
|
|
393
|
+
predicates: Array<GlobalDynamicPredicateGroup | GlobalPredicateGroup>;
|
|
371
394
|
styles: Array<GlobalStyle | GlobalStyleGroup>;
|
|
372
395
|
}
|
|
373
396
|
declare const Globals = "Globals";
|
|
@@ -400,11 +423,11 @@ interface IconProperty extends AstNode {
|
|
|
400
423
|
readonly $type: 'IconProperty';
|
|
401
424
|
key: 'icon';
|
|
402
425
|
libicon?: Reference<LibIcon>;
|
|
403
|
-
value?: Uri;
|
|
426
|
+
value?: 'none' | Uri;
|
|
404
427
|
}
|
|
405
428
|
declare const IconProperty = "IconProperty";
|
|
406
429
|
interface IncludePredicate extends AstNode {
|
|
407
|
-
readonly $container: ElementViewBody | ViewRuleGroup;
|
|
430
|
+
readonly $container: ElementViewBody | GlobalPredicateGroup | ViewRuleGroup;
|
|
408
431
|
readonly $type: 'IncludePredicate';
|
|
409
432
|
predicates: Predicates;
|
|
410
433
|
}
|
|
@@ -684,6 +707,12 @@ interface ViewRuleAutoLayout extends AstNode {
|
|
|
684
707
|
rankSep?: number;
|
|
685
708
|
}
|
|
686
709
|
declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
|
|
710
|
+
interface ViewRuleGlobalPredicateRef extends AstNode {
|
|
711
|
+
readonly $container: ElementViewBody;
|
|
712
|
+
readonly $type: 'ViewRuleGlobalPredicateRef';
|
|
713
|
+
predicate: Reference<GlobalPredicateGroup>;
|
|
714
|
+
}
|
|
715
|
+
declare const ViewRuleGlobalPredicateRef = "ViewRuleGlobalPredicateRef";
|
|
687
716
|
interface ViewRuleGlobalStyle extends AstNode {
|
|
688
717
|
readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
|
|
689
718
|
readonly $type: 'ViewRuleGlobalStyle';
|
|
@@ -780,6 +809,7 @@ type LikeC4AstType = {
|
|
|
780
809
|
DirectedRelationExpression: DirectedRelationExpression;
|
|
781
810
|
DynamicView: DynamicView;
|
|
782
811
|
DynamicViewBody: DynamicViewBody;
|
|
812
|
+
DynamicViewGlobalPredicateRef: DynamicViewGlobalPredicateRef;
|
|
783
813
|
DynamicViewIncludePredicate: DynamicViewIncludePredicate;
|
|
784
814
|
DynamicViewParallelSteps: DynamicViewParallelSteps;
|
|
785
815
|
DynamicViewPredicateIterator: DynamicViewPredicateIterator;
|
|
@@ -810,6 +840,8 @@ type LikeC4AstType = {
|
|
|
810
840
|
ExtendElement: ExtendElement;
|
|
811
841
|
ExtendElementBody: ExtendElementBody;
|
|
812
842
|
FqnElementRef: FqnElementRef;
|
|
843
|
+
GlobalDynamicPredicateGroup: GlobalDynamicPredicateGroup;
|
|
844
|
+
GlobalPredicateGroup: GlobalPredicateGroup;
|
|
813
845
|
GlobalStyle: GlobalStyle;
|
|
814
846
|
GlobalStyleGroup: GlobalStyleGroup;
|
|
815
847
|
GlobalStyleId: GlobalStyleId;
|
|
@@ -865,6 +897,7 @@ type LikeC4AstType = {
|
|
|
865
897
|
ViewRef: ViewRef;
|
|
866
898
|
ViewRule: ViewRule;
|
|
867
899
|
ViewRuleAutoLayout: ViewRuleAutoLayout;
|
|
900
|
+
ViewRuleGlobalPredicateRef: ViewRuleGlobalPredicateRef;
|
|
868
901
|
ViewRuleGlobalStyle: ViewRuleGlobalStyle;
|
|
869
902
|
ViewRuleGroup: ViewRuleGroup;
|
|
870
903
|
ViewRulePredicate: ViewRulePredicate;
|
|
@@ -960,9 +993,7 @@ interface ParsedAstRelation {
|
|
|
960
993
|
[key: string]: string;
|
|
961
994
|
};
|
|
962
995
|
}
|
|
963
|
-
|
|
964
|
-
styles: Record<c4.GlobalStyleID, c4.NonEmptyArray<c4.ViewRuleStyle>>;
|
|
965
|
-
}
|
|
996
|
+
type ParsedAstGlobals = c4.ModelGlobals;
|
|
966
997
|
interface ParsedAstElementView {
|
|
967
998
|
__: 'element';
|
|
968
999
|
id: c4.ViewID;
|
|
@@ -1015,7 +1046,7 @@ interface ParsedLikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar
|
|
|
1015
1046
|
}
|
|
1016
1047
|
type Guard<N extends AstNode> = (n: AstNode) => n is N;
|
|
1017
1048
|
type Guarded<G> = G extends Guard<infer N> ? N : never;
|
|
1018
|
-
declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isGlobals | typeof isGlobalStyle | typeof isGlobalStyleGroup | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
|
|
1049
|
+
declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isGlobals | typeof isGlobalPredicateGroup | typeof isGlobalDynamicPredicateGroup | typeof isGlobalStyle | typeof isGlobalStyleGroup | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
|
|
1019
1050
|
type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
|
|
1020
1051
|
declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
|
|
1021
1052
|
isValid: (n: ValidatableAstNode) => boolean;
|
|
@@ -1135,8 +1166,10 @@ declare class LikeC4ModelParser {
|
|
|
1135
1166
|
private parseElement;
|
|
1136
1167
|
private parseRelation;
|
|
1137
1168
|
private parseGlobal;
|
|
1169
|
+
private parseAndStoreGlobalPredicateGroupOrDynamic;
|
|
1170
|
+
private parseGlobalPredicateGroup;
|
|
1171
|
+
private parseGlobalDynamicPredicateGroup;
|
|
1138
1172
|
private parseGlobalStyleOrGroup;
|
|
1139
|
-
private parseGlobalStyle;
|
|
1140
1173
|
private parseViews;
|
|
1141
1174
|
private parseViewRulePredicate;
|
|
1142
1175
|
private parsePredicate;
|
|
@@ -1150,6 +1183,7 @@ declare class LikeC4ModelParser {
|
|
|
1150
1183
|
private parseRelationPredicateWith;
|
|
1151
1184
|
private parseRelationExpr;
|
|
1152
1185
|
private parseViewRule;
|
|
1186
|
+
private parseViewRuleGlobalPredicateRef;
|
|
1153
1187
|
private parseViewRuleStyleOrGlobalRef;
|
|
1154
1188
|
private parseViewRuleStyle;
|
|
1155
1189
|
private parseViewRuleGroup;
|