@likec4/language-server 1.20.0 → 1.20.2
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/README.md +19 -0
- package/bin/likec4-language-server.mjs +5 -0
- package/dist/LikeC4FileSystem.js +9 -9
- package/dist/Rpc.d.ts +2 -4
- package/dist/Rpc.js +27 -36
- package/dist/ast.d.ts +1 -0
- package/dist/ast.js +5 -1
- package/dist/bundled.mjs +5924 -0
- package/dist/formatting/LikeC4Formatter.d.ts +9 -0
- package/dist/formatting/LikeC4Formatter.js +131 -14
- package/dist/generated/ast.d.ts +13 -2
- package/dist/generated/ast.js +18 -1
- package/dist/generated/grammar.js +1 -1
- package/dist/lsp/CompletionProvider.js +11 -3
- package/dist/model/deployments-index.d.ts +2 -1
- package/dist/model/deployments-index.js +3 -10
- package/dist/model/fqn-index.d.ts +2 -1
- package/dist/model/fqn-index.js +24 -17
- package/dist/model/model-builder.d.ts +2 -1
- package/dist/model/model-builder.js +32 -30
- package/dist/model/model-parser.d.ts +1 -1
- package/dist/model/model-parser.js +9 -6
- package/dist/model/parser/PredicatesParser.js +7 -1
- package/dist/utils/disposable.d.ts +8 -0
- package/dist/utils/disposable.js +25 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/validation/_shared.js +4 -1
- package/dist/validation/index.d.ts +2 -2
- package/dist/validation/index.js +4 -1
- package/dist/validation/specification.d.ts +1 -0
- package/dist/validation/specification.js +30 -0
- package/package.json +33 -27
- package/src/LikeC4FileSystem.ts +14 -13
- package/src/Rpc.ts +28 -38
- package/src/ast.ts +6 -1
- package/src/formatting/LikeC4Formatter.ts +198 -17
- package/src/generated/ast.ts +35 -2
- package/src/generated/grammar.ts +1 -1
- package/src/like-c4.langium +14 -3
- package/src/lsp/CompletionProvider.ts +27 -18
- package/src/model/deployments-index.ts +4 -17
- package/src/model/fqn-index.ts +26 -19
- package/src/model/model-builder.ts +32 -31
- package/src/model/model-parser.ts +14 -11
- package/src/model/parser/PredicatesParser.ts +30 -24
- package/src/utils/disposable.ts +30 -0
- package/src/utils/index.ts +1 -0
- package/src/validation/_shared.ts +5 -2
- package/src/validation/index.ts +6 -2
- package/src/validation/specification.ts +34 -0
- package/contrib/likec4.tmLanguage.json +0 -73
- package/dist/like-c4.langium +0 -852
|
@@ -3,6 +3,7 @@ import { AbstractFormatter } from 'langium/lsp';
|
|
|
3
3
|
export declare class LikeC4Formatter extends AbstractFormatter {
|
|
4
4
|
protected format(node: AstNode): void;
|
|
5
5
|
protected formatTags(node: AstNode): void;
|
|
6
|
+
protected formatDeploymentRelation(node: AstNode): void;
|
|
6
7
|
protected formatRelation(node: AstNode): void;
|
|
7
8
|
protected removeIndentFromTopLevelStatements(node: AstNode): void;
|
|
8
9
|
protected indentContentInBraces(node: AstNode): void;
|
|
@@ -17,11 +18,19 @@ export declare class LikeC4Formatter extends AbstractFormatter {
|
|
|
17
18
|
protected formatGlobals(node: AstNode): void;
|
|
18
19
|
protected formatSpecificationRule(node: AstNode): void;
|
|
19
20
|
protected formatWithPredicate(node: AstNode): void;
|
|
21
|
+
protected formatDeploymentNodeDeclaration(node: AstNode): void;
|
|
22
|
+
protected formatDeployedInstance(node: AstNode): void;
|
|
20
23
|
protected formatViewRuleGlobalStyle(node: AstNode): void;
|
|
24
|
+
protected formatViewRuleGlobalPredicate(node: AstNode): void;
|
|
21
25
|
protected formatViewRuleGroup(node: AstNode): void;
|
|
22
26
|
protected formatViewRuleStyle(node: AstNode): void;
|
|
23
27
|
protected formatWhereExpression(node: AstNode): void;
|
|
28
|
+
protected formatWhereExpressionV2(node: AstNode): void;
|
|
29
|
+
protected formatWhereRelationExpression(node: AstNode): void;
|
|
30
|
+
protected formatWhereElementExpression(node: AstNode): void;
|
|
24
31
|
protected formatIncludeExcludeExpressions(node: AstNode): void;
|
|
32
|
+
protected formatRelationExpression(node: AstNode): void;
|
|
33
|
+
protected formatDeploymentViewRulePredicateExpressions(node: AstNode): void;
|
|
25
34
|
private findPredicateExpressionRoot;
|
|
26
35
|
private on;
|
|
27
36
|
}
|
|
@@ -19,11 +19,20 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
19
19
|
this.formatElementDeclaration(node);
|
|
20
20
|
this.formatRelation(node);
|
|
21
21
|
this.formatMetadataProperty(node);
|
|
22
|
+
this.formatDeploymentNodeDeclaration(node);
|
|
23
|
+
this.formatDeployedInstance(node);
|
|
24
|
+
this.formatDeploymentRelation(node);
|
|
22
25
|
this.formatView(node);
|
|
23
26
|
this.formatViewRuleGroup(node);
|
|
24
27
|
this.formatViewRuleGlobalStyle(node);
|
|
28
|
+
this.formatViewRuleGlobalPredicate(node);
|
|
25
29
|
this.formatIncludeExcludeExpressions(node);
|
|
30
|
+
this.formatDeploymentViewRulePredicateExpressions(node);
|
|
26
31
|
this.formatWhereExpression(node);
|
|
32
|
+
this.formatWhereExpressionV2(node);
|
|
33
|
+
this.formatWhereRelationExpression(node);
|
|
34
|
+
this.formatWhereElementExpression(node);
|
|
35
|
+
this.formatRelationExpression(node);
|
|
27
36
|
this.formatAutolayoutProperty(node);
|
|
28
37
|
this.formatWithPredicate(node);
|
|
29
38
|
this.formatViewRuleStyle(node);
|
|
@@ -38,6 +47,19 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
38
47
|
f.keywords(",").prepend(FormattingOptions.noSpace).append(FormattingOptions.oneSpace);
|
|
39
48
|
});
|
|
40
49
|
}
|
|
50
|
+
formatDeploymentRelation(node) {
|
|
51
|
+
this.on(node, ast.isDeploymentRelation, (n, f) => {
|
|
52
|
+
const sourceNodes = n?.source?.$cstNode ? [n?.source?.$cstNode] : [];
|
|
53
|
+
f.cst(sourceNodes).append(FormattingOptions.oneSpace);
|
|
54
|
+
f.keywords("]->").prepend(FormattingOptions.noSpace);
|
|
55
|
+
f.keywords("-[").append(FormattingOptions.noSpace);
|
|
56
|
+
f.nodes(...filter([
|
|
57
|
+
n.target,
|
|
58
|
+
n.tags
|
|
59
|
+
], isTruthy)).prepend(FormattingOptions.oneSpace);
|
|
60
|
+
f.properties("title", "technology").prepend(FormattingOptions.oneSpace);
|
|
61
|
+
});
|
|
62
|
+
}
|
|
41
63
|
formatRelation(node) {
|
|
42
64
|
this.on(node, ast.isRelation, (n, f) => {
|
|
43
65
|
const sourceNodes = n?.source?.$cstNode ? [n?.source?.$cstNode] : [];
|
|
@@ -68,13 +90,13 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
68
90
|
this.on(node, ast.isInOutRelationExpression)?.keyword("->").prepend(FormattingOptions.oneSpace);
|
|
69
91
|
}
|
|
70
92
|
removeIndentFromTopLevelStatements(node) {
|
|
71
|
-
if (ast.isModel(node) || ast.isSpecificationRule(node) || ast.isModelViews(node) || ast.isLikeC4Lib(node) || ast.isGlobals(node)) {
|
|
93
|
+
if (ast.isModel(node) || ast.isSpecificationRule(node) || ast.isModelViews(node) || ast.isLikeC4Lib(node) || ast.isGlobals(node) || ast.isModelDeployments(node)) {
|
|
72
94
|
const formatter = this.getNodeFormatter(node);
|
|
73
|
-
formatter.keywords("specification", "model", "views", "likec4lib", "global").prepend(FormattingOptions.noIndent);
|
|
95
|
+
formatter.keywords("specification", "model", "views", "likec4lib", "global", "deployments").prepend(FormattingOptions.noIndent);
|
|
74
96
|
}
|
|
75
97
|
}
|
|
76
98
|
indentContentInBraces(node) {
|
|
77
|
-
if (ast.isLikeC4Lib(node) || ast.isSpecificationRule(node) || ast.isSpecificationElementKind(node) || ast.isSpecificationRelationshipKind(node) || ast.isGlobals(node) || ast.isGlobalStyle(node) || ast.isGlobalStyleGroup(node) || ast.isModel(node) || ast.isElementBody(node) || ast.isExtendElementBody(node) || ast.isRelationBody(node) || ast.isRelationStyleProperty(node) || ast.isMetadataBody(node) || ast.isModelViews(node) || ast.isElementViewBody(node) || ast.isDynamicViewBody(node) || ast.isViewRuleStyle(node) || ast.isViewRuleGroup(node) || ast.isCustomElementProperties(node) || ast.isCustomRelationProperties(node) || ast.isElementStyleProperty(node) || ast.isDynamicViewParallelSteps(node)) {
|
|
99
|
+
if (ast.isLikeC4Lib(node) || ast.isSpecificationRule(node) || ast.isSpecificationElementKind(node) || ast.isSpecificationRelationshipKind(node) || ast.isSpecificationDeploymentNodeKind(node) || ast.isGlobals(node) || ast.isGlobalStyle(node) || ast.isGlobalStyleGroup(node) || ast.isGlobalPredicateGroup(node) || ast.isGlobalDynamicPredicateGroup(node) || ast.isGlobalStyleGroup(node) || ast.isModel(node) || ast.isElementBody(node) || ast.isExtendElementBody(node) || ast.isRelationBody(node) || ast.isRelationStyleProperty(node) || ast.isMetadataBody(node) || ast.isModelViews(node) || ast.isElementViewBody(node) || ast.isDynamicViewBody(node) || ast.isDeploymentViewBody(node) || ast.isViewRuleStyle(node) || ast.isViewRuleGroup(node) || ast.isCustomElementProperties(node) || ast.isCustomRelationProperties(node) || ast.isElementStyleProperty(node) || ast.isDynamicViewParallelSteps(node) || ast.isModelDeployments(node) || ast.isDeploymentNodeBody(node) || ast.isDeploymentRelationBody(node) || ast.isDeployedInstanceBody(node)) {
|
|
78
100
|
const formatter = this.getNodeFormatter(node);
|
|
79
101
|
const openBrace = formatter.keywords("{");
|
|
80
102
|
const closeBrace = formatter.keywords("}");
|
|
@@ -101,9 +123,10 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
101
123
|
f.keywords("of", "extends").surround(FormattingOptions.oneSpace);
|
|
102
124
|
});
|
|
103
125
|
this.on(node, ast.isDynamicView)?.keywords("dynamic", "view").append(FormattingOptions.oneSpace);
|
|
126
|
+
this.on(node, ast.isDeploymentView)?.keywords("deployment", "view").append(FormattingOptions.oneSpace);
|
|
104
127
|
}
|
|
105
128
|
formatLeafProperty(node) {
|
|
106
|
-
if (ast.isElementStringProperty(node) || ast.isRelationStringProperty(node) || ast.isViewStringProperty(node) || ast.isNotationProperty(node) || ast.isSpecificationElementStringProperty(node) || ast.isSpecificationRelationshipStringProperty(node) || ast.isColorProperty(node) || ast.isLineProperty(node) || ast.isArrowProperty(node) || ast.isIconProperty(node) || ast.isShapeProperty(node) || ast.isBorderProperty(node) || ast.isOpacityProperty(node)) {
|
|
129
|
+
if (ast.isElementStringProperty(node) || ast.isRelationStringProperty(node) || ast.isViewStringProperty(node) || ast.isNotationProperty(node) || ast.isSpecificationElementStringProperty(node) || ast.isSpecificationRelationshipStringProperty(node) || ast.isColorProperty(node) || ast.isLineProperty(node) || ast.isArrowProperty(node) || ast.isIconProperty(node) || ast.isShapeProperty(node) || ast.isBorderProperty(node) || ast.isOpacityProperty(node) || ast.isMultipleProperty(node)) {
|
|
107
130
|
const formatter = this.getNodeFormatter(node);
|
|
108
131
|
const colon = formatter.keyword(":");
|
|
109
132
|
const propertyName = formatter.keywords(
|
|
@@ -118,7 +141,8 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
118
141
|
"icon",
|
|
119
142
|
"shape",
|
|
120
143
|
"border",
|
|
121
|
-
"opacity"
|
|
144
|
+
"opacity",
|
|
145
|
+
"multiple"
|
|
122
146
|
);
|
|
123
147
|
if (colon.nodes.length === 0) {
|
|
124
148
|
propertyName.append(FormattingOptions.oneSpace);
|
|
@@ -176,11 +200,17 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
176
200
|
this.on(node, ast.isGlobalStyleGroup, (n, f) => {
|
|
177
201
|
f.keyword("styleGroup").append(FormattingOptions.oneSpace);
|
|
178
202
|
});
|
|
203
|
+
this.on(node, ast.isGlobalPredicateGroup, (n, f) => {
|
|
204
|
+
f.keyword("predicateGroup").append(FormattingOptions.oneSpace);
|
|
205
|
+
});
|
|
206
|
+
this.on(node, ast.isGlobalDynamicPredicateGroup, (n, f) => {
|
|
207
|
+
f.keyword("dynamicPredicateGroup").append(FormattingOptions.oneSpace);
|
|
208
|
+
});
|
|
179
209
|
}
|
|
180
210
|
formatSpecificationRule(node) {
|
|
181
|
-
if (ast.isSpecificationElementKind(node) || ast.isSpecificationRelationshipKind(node) || ast.isSpecificationTag(node)) {
|
|
211
|
+
if (ast.isSpecificationElementKind(node) || ast.isSpecificationRelationshipKind(node) || ast.isSpecificationTag(node) || ast.isSpecificationDeploymentNodeKind(node)) {
|
|
182
212
|
const formatter = this.getNodeFormatter(node);
|
|
183
|
-
formatter.keywords("element", "relationship", "tag").append(FormattingOptions.oneSpace);
|
|
213
|
+
formatter.keywords("element", "relationship", "tag", "deploymentNode").append(FormattingOptions.oneSpace);
|
|
184
214
|
}
|
|
185
215
|
if (ast.isSpecificationColor(node)) {
|
|
186
216
|
const formatter = this.getNodeFormatter(node);
|
|
@@ -194,11 +224,42 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
194
224
|
formatter.keyword("with").prepend(FormattingOptions.oneSpace);
|
|
195
225
|
}
|
|
196
226
|
}
|
|
227
|
+
formatDeploymentNodeDeclaration(node) {
|
|
228
|
+
this.on(node, ast.isDeploymentNode, (n, f) => {
|
|
229
|
+
const kind = GrammarUtils.findNodeForProperty(n.$cstNode, "kind");
|
|
230
|
+
const name = GrammarUtils.findNodeForProperty(n.$cstNode, "name");
|
|
231
|
+
if (name && kind) {
|
|
232
|
+
if (utils.compareRanges(name, kind) > 0) {
|
|
233
|
+
f.cst([kind]).append(FormattingOptions.oneSpace);
|
|
234
|
+
} else {
|
|
235
|
+
f.cst([name]).append(FormattingOptions.oneSpace);
|
|
236
|
+
f.cst([kind]).prepend(FormattingOptions.oneSpace);
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
f.properties("title").prepend(FormattingOptions.oneSpace);
|
|
240
|
+
});
|
|
241
|
+
}
|
|
242
|
+
formatDeployedInstance(node) {
|
|
243
|
+
this.on(node, ast.isDeployedInstance, (n, f) => {
|
|
244
|
+
const eqNode = n.$cstNode?.content.find((c) => c.text === "=");
|
|
245
|
+
if (eqNode) {
|
|
246
|
+
f.cst([eqNode]).surround(FormattingOptions.oneSpace);
|
|
247
|
+
}
|
|
248
|
+
f.keyword("instanceOf").append(FormattingOptions.oneSpace);
|
|
249
|
+
f.property("title").prepend(FormattingOptions.oneSpace);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
197
252
|
formatViewRuleGlobalStyle(node) {
|
|
198
253
|
this.on(node, ast.isViewRuleGlobalStyle, (n, f) => {
|
|
199
254
|
f.keywords("global", "style").append(FormattingOptions.oneSpace);
|
|
200
255
|
});
|
|
201
256
|
}
|
|
257
|
+
formatViewRuleGlobalPredicate(node) {
|
|
258
|
+
const formatter = this.getNodeFormatter(node);
|
|
259
|
+
if (ast.isViewRuleGlobalPredicateRef(node) || ast.isDynamicViewGlobalPredicateRef(node)) {
|
|
260
|
+
formatter.keywords("global", "predicate").append(FormattingOptions.oneSpace);
|
|
261
|
+
}
|
|
262
|
+
}
|
|
202
263
|
formatViewRuleGroup(node) {
|
|
203
264
|
this.on(node, ast.isViewRuleGroup, (n, f) => {
|
|
204
265
|
f.keyword("group").append(FormattingOptions.oneSpace);
|
|
@@ -206,29 +267,50 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
206
267
|
}
|
|
207
268
|
formatViewRuleStyle(node) {
|
|
208
269
|
this.on(node, ast.isViewRuleStyle)?.keyword("style").append(FormattingOptions.oneSpace);
|
|
270
|
+
this.on(node, ast.isDeploymentViewRuleStyle)?.keyword("style").append(FormattingOptions.oneSpace);
|
|
209
271
|
this.on(node, ast.isElementExpressionsIterator)?.keyword(",").prepend(FormattingOptions.noSpace).append(FormattingOptions.oneSpace);
|
|
272
|
+
this.on(node, ast.isFqnExpressions)?.keyword(",").prepend(FormattingOptions.noSpace).append(FormattingOptions.oneSpace);
|
|
210
273
|
}
|
|
211
274
|
formatWhereExpression(node) {
|
|
212
275
|
if (ast.isRelationPredicateOrWhere(node) || ast.isElementPredicateOrWhere(node)) {
|
|
213
276
|
const formatter = this.getNodeFormatter(node);
|
|
214
277
|
formatter.keyword("where").append(FormattingOptions.oneSpace);
|
|
215
278
|
}
|
|
216
|
-
|
|
279
|
+
}
|
|
280
|
+
formatWhereExpressionV2(node) {
|
|
281
|
+
if (ast.isRelationPredicateOrWhereV2(node)) {
|
|
217
282
|
const formatter = this.getNodeFormatter(node);
|
|
218
|
-
formatter.
|
|
283
|
+
formatter.keyword("where").append(FormattingOptions.oneSpace);
|
|
219
284
|
}
|
|
220
|
-
|
|
285
|
+
}
|
|
286
|
+
formatWhereRelationExpression(node) {
|
|
287
|
+
this.on(node, ast.isWhereRelationExpression, (n, f) => {
|
|
288
|
+
f.property("operator").surround(FormattingOptions.oneSpace);
|
|
289
|
+
});
|
|
290
|
+
this.on(node, ast.isWhereRelationNegation, (n, f) => {
|
|
291
|
+
f.keyword("not").append(FormattingOptions.oneSpace);
|
|
292
|
+
});
|
|
293
|
+
if (ast.isWhereRelation(node) || ast.isWhereRelationTag(node) || ast.isWhereRelationKind(node)) {
|
|
221
294
|
const formatter = this.getNodeFormatter(node);
|
|
222
|
-
formatter.
|
|
295
|
+
formatter.property("operator").surround(FormattingOptions.oneSpace);
|
|
296
|
+
formatter.property("not").surround(FormattingOptions.oneSpace);
|
|
223
297
|
}
|
|
224
|
-
|
|
298
|
+
}
|
|
299
|
+
formatWhereElementExpression(node) {
|
|
300
|
+
this.on(node, ast.isWhereElementExpression, (n, f) => {
|
|
301
|
+
f.property("operator").surround(FormattingOptions.oneSpace);
|
|
302
|
+
});
|
|
303
|
+
this.on(node, ast.isWhereElementNegation, (n, f) => {
|
|
304
|
+
f.keyword("not").append(FormattingOptions.oneSpace);
|
|
305
|
+
});
|
|
306
|
+
if (ast.isWhereElement(node) || ast.isWhereElementTag(node) || ast.isWhereElementKind(node)) {
|
|
225
307
|
const formatter = this.getNodeFormatter(node);
|
|
226
308
|
formatter.property("operator").surround(FormattingOptions.oneSpace);
|
|
227
309
|
formatter.property("not").surround(FormattingOptions.oneSpace);
|
|
228
310
|
}
|
|
229
311
|
}
|
|
230
312
|
formatIncludeExcludeExpressions(node) {
|
|
231
|
-
if (ast.isDynamicViewRule(node) || ast.isIncludePredicate(node) || ast.isExcludePredicate(node)) {
|
|
313
|
+
if (ast.isDynamicViewRule(node) || ast.isIncludePredicate(node) || ast.isExcludePredicate(node) || ast.isDeploymentViewRulePredicate(node)) {
|
|
232
314
|
const formatter = this.getNodeFormatter(node);
|
|
233
315
|
if (!node.$cstNode || !utils.isMultiline(node.$cstNode)) {
|
|
234
316
|
formatter.keywords("include", "exclude").append(FormattingOptions.oneSpace);
|
|
@@ -244,10 +326,45 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
244
326
|
formatter.keyword(",").prepend(FormattingOptions.noSpace).append(isMultiline ? FormattingOptions.newLine : FormattingOptions.oneSpace);
|
|
245
327
|
}
|
|
246
328
|
}
|
|
329
|
+
formatRelationExpression(node) {
|
|
330
|
+
this.on(node, ast.isIncomingRelationExpr, (n, f) => {
|
|
331
|
+
f.keyword("->").append(FormattingOptions.oneSpace);
|
|
332
|
+
});
|
|
333
|
+
this.on(node, ast.isInOutRelationExpr, (n, f) => {
|
|
334
|
+
f.keyword("->").prepend(FormattingOptions.oneSpace);
|
|
335
|
+
});
|
|
336
|
+
this.on(node, ast.isOutgoingRelationExpr, (n, f) => {
|
|
337
|
+
f.keywords("->", "<->").prepend(FormattingOptions.oneSpace);
|
|
338
|
+
f.keywords("-[").prepend(FormattingOptions.oneSpace).append(FormattingOptions.noSpace);
|
|
339
|
+
f.keywords("]->").prepend(FormattingOptions.noSpace).append(FormattingOptions.oneSpace);
|
|
340
|
+
const kind = f.property("kind");
|
|
341
|
+
kind.nodes[0]?.text.startsWith(".") && kind.surround(FormattingOptions.oneSpace);
|
|
342
|
+
});
|
|
343
|
+
this.on(node, ast.isDirectedRelationExpr, (n, f) => {
|
|
344
|
+
f.property("target").prepend(FormattingOptions.oneSpace);
|
|
345
|
+
});
|
|
346
|
+
}
|
|
347
|
+
formatDeploymentViewRulePredicateExpressions(node) {
|
|
348
|
+
if (ast.isDynamicViewRule(node) || ast.isIncludePredicate(node) || ast.isExcludePredicate(node) || ast.isDeploymentViewRulePredicate(node)) {
|
|
349
|
+
const formatter = this.getNodeFormatter(node);
|
|
350
|
+
if (!node.$cstNode || !utils.isMultiline(node.$cstNode)) {
|
|
351
|
+
formatter.keywords("include", "exclude").append(FormattingOptions.oneSpace);
|
|
352
|
+
}
|
|
353
|
+
}
|
|
354
|
+
if (ast.isDeploymentViewRulePredicateExpression(node)) {
|
|
355
|
+
const formatter = this.getNodeFormatter(node);
|
|
356
|
+
const parent = this.findPredicateExpressionRoot(node);
|
|
357
|
+
const isMultiline = parent?.$cstNode && utils.isMultiline(parent?.$cstNode);
|
|
358
|
+
if (isMultiline) {
|
|
359
|
+
formatter.property("value").prepend(FormattingOptions.indent);
|
|
360
|
+
}
|
|
361
|
+
formatter.keyword(",").prepend(FormattingOptions.noSpace).append(isMultiline ? FormattingOptions.newLine : FormattingOptions.oneSpace);
|
|
362
|
+
}
|
|
363
|
+
}
|
|
247
364
|
findPredicateExpressionRoot(node) {
|
|
248
365
|
let parent = node.$container;
|
|
249
366
|
while (true) {
|
|
250
|
-
if (!parent || ast.isDynamicViewRule(parent) || ast.isIncludePredicate(parent) || ast.isExcludePredicate(parent)) {
|
|
367
|
+
if (!parent || ast.isDynamicViewRule(parent) || ast.isIncludePredicate(parent) || ast.isExcludePredicate(parent) || ast.isDeploymentViewRulePredicate(parent)) {
|
|
251
368
|
return parent;
|
|
252
369
|
}
|
|
253
370
|
parent = parent.$container;
|
package/dist/generated/ast.d.ts
CHANGED
|
@@ -26,10 +26,12 @@ export declare const LikeC4Terminals: {
|
|
|
26
26
|
Hex: RegExp;
|
|
27
27
|
};
|
|
28
28
|
export type LikeC4TerminalNames = keyof typeof LikeC4Terminals;
|
|
29
|
-
export type LikeC4KeywordNames = "(" | ")" | "*" | "," | "->" | "-[" | ":" | ";" | "<-" | "<->" | "BottomTop" | "LeftRight" | "RightLeft" | "TopBottom" | "]->" | "amber" | "and" | "autoLayout" | "blue" | "border" | "browser" | "color" | "crow" | "cylinder" | "dashed" | "deployment" | "deploymentNode" | "description" | "diamond" | "dot" | "dotted" | "dynamic" | "dynamicPredicateGroup" | "element" | "element.kind" | "element.tag" | "exclude" | "extend" | "extends" | "global" | "gray" | "green" | "group" | "head" | "icon" | "icons" | "include" | "indigo" | "instance" | "instanceOf" | "is" | "kind" | "likec4lib" | "line" | "link" | "metadata" | "mobile" | "model" | "muted" | "navigateTo" | "node" | "none" | "normal" | "not" | "notation" | "notes" | "odiamond" | "odot" | "of" | "onormal" | "opacity" | "open" | "or" | "par" | "parallel" | "person" | "predicate" | "predicateGroup" | "primary" | "queue" | "rectangle" | "red" | "relationship" | "secondary" | "shape" | "sky" | "slate" | "solid" | "source" | "specification" | "storage" | "style" | "styleGroup" | "tag" | "tail" | "target" | "technology" | "title" | "vee" | "view" | "views" | "where" | "with" | "{" | "}";
|
|
29
|
+
export type LikeC4KeywordNames = "(" | ")" | "*" | "," | "->" | "-[" | ":" | ";" | "<-" | "<->" | "BottomTop" | "LeftRight" | "RightLeft" | "TopBottom" | "]->" | "amber" | "and" | "autoLayout" | "blue" | "border" | "browser" | "color" | "crow" | "cylinder" | "dashed" | "deployment" | "deploymentNode" | "description" | "diamond" | "dot" | "dotted" | "dynamic" | "dynamicPredicateGroup" | "element" | "element.kind" | "element.tag" | "exclude" | "extend" | "extends" | "false" | "global" | "gray" | "green" | "group" | "head" | "icon" | "icons" | "include" | "indigo" | "instance" | "instanceOf" | "is" | "kind" | "likec4lib" | "line" | "link" | "metadata" | "mobile" | "model" | "multiple" | "muted" | "navigateTo" | "node" | "none" | "normal" | "not" | "notation" | "notes" | "odiamond" | "odot" | "of" | "onormal" | "opacity" | "open" | "or" | "par" | "parallel" | "person" | "predicate" | "predicateGroup" | "primary" | "queue" | "rectangle" | "red" | "relationship" | "secondary" | "shape" | "sky" | "slate" | "solid" | "source" | "specification" | "storage" | "style" | "styleGroup" | "tag" | "tail" | "target" | "technology" | "title" | "true" | "vee" | "view" | "views" | "where" | "with" | "{" | "}";
|
|
30
30
|
export type LikeC4TokenNames = LikeC4TerminalNames | LikeC4KeywordNames;
|
|
31
31
|
export type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | 'odot' | 'onormal' | 'open' | 'vee';
|
|
32
32
|
export declare function isArrowType(item: unknown): item is ArrowType;
|
|
33
|
+
export type Boolean = boolean;
|
|
34
|
+
export declare function isBoolean(item: unknown): item is Boolean;
|
|
33
35
|
export type BorderStyleValue = 'none' | LineOptions;
|
|
34
36
|
export declare function isBorderStyleValue(item: unknown): item is BorderStyleValue;
|
|
35
37
|
export type CustomColorId = 'element' | 'model' | ArrowType | ElementShape | LineOptions | string;
|
|
@@ -117,7 +119,7 @@ export declare function isRelationshipStyleProperty(item: unknown): item is Rela
|
|
|
117
119
|
export type StringProperty = ElementStringProperty | MetadataAttribute | NotationProperty | NotesProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
|
|
118
120
|
export declare const StringProperty = "StringProperty";
|
|
119
121
|
export declare function isStringProperty(item: unknown): item is StringProperty;
|
|
120
|
-
export type StyleProperty = BorderProperty | ColorProperty | IconProperty | OpacityProperty | ShapeProperty;
|
|
122
|
+
export type StyleProperty = BorderProperty | ColorProperty | IconProperty | MultipleProperty | OpacityProperty | ShapeProperty;
|
|
121
123
|
export declare const StyleProperty = "StyleProperty";
|
|
122
124
|
export declare function isStyleProperty(item: unknown): item is StyleProperty;
|
|
123
125
|
export type TagId = string;
|
|
@@ -755,6 +757,14 @@ export interface ModelViews extends AstNode {
|
|
|
755
757
|
}
|
|
756
758
|
export declare const ModelViews = "ModelViews";
|
|
757
759
|
export declare function isModelViews(item: unknown): item is ModelViews;
|
|
760
|
+
export interface MultipleProperty extends AstNode {
|
|
761
|
+
readonly $container: CustomElementProperties | DeploymentViewRuleStyle | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
|
|
762
|
+
readonly $type: 'MultipleProperty';
|
|
763
|
+
key: 'multiple';
|
|
764
|
+
value: Boolean;
|
|
765
|
+
}
|
|
766
|
+
export declare const MultipleProperty = "MultipleProperty";
|
|
767
|
+
export declare function isMultipleProperty(item: unknown): item is MultipleProperty;
|
|
758
768
|
export interface NavigateToProperty extends AstNode {
|
|
759
769
|
readonly $container: CustomElementProperties;
|
|
760
770
|
readonly $type: 'NavigateToProperty';
|
|
@@ -1207,6 +1217,7 @@ export type LikeC4AstType = {
|
|
|
1207
1217
|
Model: Model;
|
|
1208
1218
|
ModelDeployments: ModelDeployments;
|
|
1209
1219
|
ModelViews: ModelViews;
|
|
1220
|
+
MultipleProperty: MultipleProperty;
|
|
1210
1221
|
NavigateToProperty: NavigateToProperty;
|
|
1211
1222
|
NotationProperty: NotationProperty;
|
|
1212
1223
|
NotesProperty: NotesProperty;
|
package/dist/generated/ast.js
CHANGED
|
@@ -23,6 +23,9 @@ export const LikeC4Terminals = {
|
|
|
23
23
|
export function isArrowType(item) {
|
|
24
24
|
return item === "none" || item === "normal" || item === "onormal" || item === "dot" || item === "odot" || item === "diamond" || item === "odiamond" || item === "crow" || item === "open" || item === "vee";
|
|
25
25
|
}
|
|
26
|
+
export function isBoolean(item) {
|
|
27
|
+
return typeof item === "boolean";
|
|
28
|
+
}
|
|
26
29
|
export function isBorderStyleValue(item) {
|
|
27
30
|
return isLineOptions(item) || item === "none";
|
|
28
31
|
}
|
|
@@ -494,6 +497,10 @@ export const ModelViews = "ModelViews";
|
|
|
494
497
|
export function isModelViews(item) {
|
|
495
498
|
return reflection.isInstance(item, ModelViews);
|
|
496
499
|
}
|
|
500
|
+
export const MultipleProperty = "MultipleProperty";
|
|
501
|
+
export function isMultipleProperty(item) {
|
|
502
|
+
return reflection.isInstance(item, MultipleProperty);
|
|
503
|
+
}
|
|
497
504
|
export const NavigateToProperty = "NavigateToProperty";
|
|
498
505
|
export function isNavigateToProperty(item) {
|
|
499
506
|
return reflection.isInstance(item, NavigateToProperty);
|
|
@@ -672,7 +679,7 @@ export function isWildcardExpression(item) {
|
|
|
672
679
|
}
|
|
673
680
|
export class LikeC4AstReflection extends AbstractAstReflection {
|
|
674
681
|
getAllTypes() {
|
|
675
|
-
return [ArrowProperty, BorderProperty, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DeployedInstance, DeployedInstanceBody, DeploymentElement, DeploymentNode, DeploymentNodeBody, DeploymentNodeKind, DeploymentNodeOrElementKind, DeploymentRelation, DeploymentRelationBody, DeploymentView, DeploymentViewBody, DeploymentViewRule, DeploymentViewRulePredicate, DeploymentViewRulePredicateExpression, DeploymentViewRuleStyle, DirectedRelationExpr, DirectedRelationExpression, DynamicView, DynamicViewBody, DynamicViewGlobalPredicateRef, DynamicViewIncludePredicate, DynamicViewParallelSteps, DynamicViewPredicateIterator, DynamicViewRef, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementDescedantsExpression, ElementExpression, ElementExpressionsIterator, ElementKind, ElementKindExpression, ElementPredicate, ElementPredicateOrWhere, ElementPredicateWhere, ElementPredicateWith, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExcludePredicate, ExpandElementExpression, ExpressionV2, ExtendElement, ExtendElementBody, FqnElementRef, FqnExpr, FqnExpressions, FqnRef, FqnRefExpr, FqnReferenceable, GlobalDynamicPredicateGroup, GlobalPredicateGroup, GlobalStyle, GlobalStyleGroup, GlobalStyleId, Globals, IconProperty, InOutRelationExpr, InOutRelationExpression, IncludePredicate, IncomingRelationExpr, IncomingRelationExpression, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelDeployments, ModelViews, NavigateToProperty, NotationProperty, NotesProperty, OpacityProperty, OutgoingRelationExpr, OutgoingRelationExpression, Predicate, Predicates, Referenceable, Relation, RelationBody, RelationExpr, RelationExpression, RelationNavigateToProperty, RelationPredicate, RelationPredicateOrWhere, RelationPredicateOrWhereV2, RelationPredicateWhere, RelationPredicateWhereV2, RelationPredicateWith, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, SpecificationColor, SpecificationDeploymentNodeKind, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StringProperty, StyleProperty, Tag, Tags, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRuleGlobalPredicateRef, ViewRuleGlobalStyle, ViewRuleGroup, ViewRulePredicate, ViewRuleStyle, ViewRuleStyleOrGlobalRef, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationParticipantKind, WhereRelationParticipantTag, WhereRelationTag, WhereTagEqual, WildcardExpression];
|
|
682
|
+
return [ArrowProperty, BorderProperty, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DeployedInstance, DeployedInstanceBody, DeploymentElement, DeploymentNode, DeploymentNodeBody, DeploymentNodeKind, DeploymentNodeOrElementKind, DeploymentRelation, DeploymentRelationBody, DeploymentView, DeploymentViewBody, DeploymentViewRule, DeploymentViewRulePredicate, DeploymentViewRulePredicateExpression, DeploymentViewRuleStyle, DirectedRelationExpr, DirectedRelationExpression, DynamicView, DynamicViewBody, DynamicViewGlobalPredicateRef, DynamicViewIncludePredicate, DynamicViewParallelSteps, DynamicViewPredicateIterator, DynamicViewRef, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementDescedantsExpression, ElementExpression, ElementExpressionsIterator, ElementKind, ElementKindExpression, ElementPredicate, ElementPredicateOrWhere, ElementPredicateWhere, ElementPredicateWith, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExcludePredicate, ExpandElementExpression, ExpressionV2, ExtendElement, ExtendElementBody, FqnElementRef, FqnExpr, FqnExpressions, FqnRef, FqnRefExpr, FqnReferenceable, GlobalDynamicPredicateGroup, GlobalPredicateGroup, GlobalStyle, GlobalStyleGroup, GlobalStyleId, Globals, IconProperty, InOutRelationExpr, InOutRelationExpression, IncludePredicate, IncomingRelationExpr, IncomingRelationExpression, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelDeployments, ModelViews, MultipleProperty, NavigateToProperty, NotationProperty, NotesProperty, OpacityProperty, OutgoingRelationExpr, OutgoingRelationExpression, Predicate, Predicates, Referenceable, Relation, RelationBody, RelationExpr, RelationExpression, RelationNavigateToProperty, RelationPredicate, RelationPredicateOrWhere, RelationPredicateOrWhereV2, RelationPredicateWhere, RelationPredicateWhereV2, RelationPredicateWith, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, SpecificationColor, SpecificationDeploymentNodeKind, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StringProperty, StyleProperty, Tag, Tags, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRuleGlobalPredicateRef, ViewRuleGlobalStyle, ViewRuleGroup, ViewRulePredicate, ViewRuleStyle, ViewRuleStyleOrGlobalRef, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationParticipantKind, WhereRelationParticipantTag, WhereRelationTag, WhereTagEqual, WildcardExpression];
|
|
676
683
|
}
|
|
677
684
|
computeIsSubtype(subtype, supertype) {
|
|
678
685
|
switch (subtype) {
|
|
@@ -681,6 +688,7 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
681
688
|
return this.isSubtype(RelationshipStyleProperty, supertype);
|
|
682
689
|
}
|
|
683
690
|
case BorderProperty:
|
|
691
|
+
case MultipleProperty:
|
|
684
692
|
case OpacityProperty:
|
|
685
693
|
case ShapeProperty: {
|
|
686
694
|
return this.isSubtype(StyleProperty, supertype);
|
|
@@ -1592,6 +1600,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
|
|
|
1592
1600
|
]
|
|
1593
1601
|
};
|
|
1594
1602
|
}
|
|
1603
|
+
case MultipleProperty: {
|
|
1604
|
+
return {
|
|
1605
|
+
name: MultipleProperty,
|
|
1606
|
+
properties: [
|
|
1607
|
+
{ name: "key" },
|
|
1608
|
+
{ name: "value" }
|
|
1609
|
+
]
|
|
1610
|
+
};
|
|
1611
|
+
}
|
|
1595
1612
|
case NavigateToProperty: {
|
|
1596
1613
|
return {
|
|
1597
1614
|
name: NavigateToProperty,
|