@likec4/language-server 1.27.3 → 1.28.1

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.
Files changed (113) hide show
  1. package/dist/LikeC4LanguageServices.js +6 -7
  2. package/dist/ast.d.ts +16 -9
  3. package/dist/ast.js +58 -79
  4. package/dist/bundled.mjs +2161 -2141
  5. package/dist/config/schema.d.ts +3 -3
  6. package/dist/config/schema.js +12 -5
  7. package/dist/documentation/documentation-provider.js +3 -1
  8. package/dist/formatting/LikeC4Formatter.d.ts +0 -2
  9. package/dist/formatting/LikeC4Formatter.js +24 -53
  10. package/dist/generated/ast.d.ts +128 -233
  11. package/dist/generated/ast.js +136 -308
  12. package/dist/generated/grammar.js +1 -1
  13. package/dist/lsp/CompletionProvider.d.ts +3 -0
  14. package/dist/lsp/CompletionProvider.js +128 -113
  15. package/dist/lsp/DocumentLinkProvider.js +6 -3
  16. package/dist/lsp/HoverProvider.js +3 -1
  17. package/dist/lsp/SemanticTokenProvider.js +33 -43
  18. package/dist/model/builder/MergedSpecification.d.ts +5 -3
  19. package/dist/model/builder/MergedSpecification.js +21 -7
  20. package/dist/model/builder/buildModel.d.ts +6 -1
  21. package/dist/model/builder/buildModel.js +20 -15
  22. package/dist/model/deployments-index.js +4 -2
  23. package/dist/model/fqn-index.d.ts +4 -2
  24. package/dist/model/fqn-index.js +28 -5
  25. package/dist/model/model-builder.d.ts +2 -2
  26. package/dist/model/model-builder.js +54 -16
  27. package/dist/model/model-locator.js +7 -4
  28. package/dist/model/model-parser.d.ts +215 -52
  29. package/dist/model/model-parser.js +6 -2
  30. package/dist/model/parser/Base.d.ts +11 -2
  31. package/dist/model/parser/Base.js +138 -3
  32. package/dist/model/parser/DeploymentModelParser.d.ts +19 -2
  33. package/dist/model/parser/DeploymentModelParser.js +19 -29
  34. package/dist/model/parser/DeploymentViewParser.d.ts +18 -2
  35. package/dist/model/parser/DeploymentViewParser.js +6 -24
  36. package/dist/model/parser/FqnRefParser.d.ts +18 -3
  37. package/dist/model/parser/FqnRefParser.js +264 -40
  38. package/dist/model/parser/GlobalsParser.d.ts +35 -18
  39. package/dist/model/parser/ImportsParser.d.ts +32 -0
  40. package/dist/model/parser/ImportsParser.js +26 -0
  41. package/dist/model/parser/ModelParser.d.ts +26 -2
  42. package/dist/model/parser/ModelParser.js +21 -41
  43. package/dist/model/parser/PredicatesParser.d.ts +35 -12
  44. package/dist/model/parser/PredicatesParser.js +20 -271
  45. package/dist/model/parser/SpecificationParser.d.ts +8 -0
  46. package/dist/model/parser/SpecificationParser.js +5 -9
  47. package/dist/model/parser/ViewsParser.d.ts +36 -19
  48. package/dist/model/parser/ViewsParser.js +16 -12
  49. package/dist/model-change/changeElementStyle.d.ts +2 -2
  50. package/dist/model-change/changeElementStyle.js +9 -6
  51. package/dist/references/name-provider.js +8 -2
  52. package/dist/references/scope-computation.d.ts +1 -1
  53. package/dist/references/scope-computation.js +33 -3
  54. package/dist/references/scope-provider.d.ts +7 -8
  55. package/dist/references/scope-provider.js +59 -41
  56. package/dist/shared/NodeKindProvider.js +4 -2
  57. package/dist/test/testServices.d.ts +2 -0
  58. package/dist/test/testServices.js +4 -1
  59. package/dist/utils/elementRef.d.ts +1 -1
  60. package/dist/utils/elementRef.js +6 -1
  61. package/dist/utils/fqnRef.d.ts +3 -0
  62. package/dist/utils/fqnRef.js +15 -4
  63. package/dist/utils/index.d.ts +1 -0
  64. package/dist/utils/index.js +9 -0
  65. package/dist/utils/projectId.d.ts +2 -1
  66. package/dist/utils/projectId.js +11 -1
  67. package/dist/validation/_shared.js +2 -2
  68. package/dist/validation/deployment-checks.js +24 -10
  69. package/dist/validation/element-ref.d.ts +4 -0
  70. package/dist/validation/element-ref.js +12 -0
  71. package/dist/validation/element.d.ts +1 -1
  72. package/dist/validation/element.js +1 -1
  73. package/dist/validation/imports.d.ts +5 -0
  74. package/dist/validation/imports.js +30 -0
  75. package/dist/validation/index.d.ts +1 -1
  76. package/dist/validation/index.js +47 -45
  77. package/dist/validation/relation.d.ts +2 -2
  78. package/dist/validation/relation.js +24 -27
  79. package/dist/validation/specification.d.ts +9 -9
  80. package/dist/validation/specification.js +9 -9
  81. package/dist/validation/view-predicates/{element-with.d.ts → fqn-expr-with.d.ts} +1 -1
  82. package/dist/validation/view-predicates/fqn-expr-with.js +42 -0
  83. package/dist/validation/view-predicates/fqn-ref-expr.d.ts +4 -0
  84. package/dist/validation/view-predicates/fqn-ref-expr.js +53 -0
  85. package/dist/validation/view-predicates/incoming.d.ts +1 -1
  86. package/dist/validation/view-predicates/incoming.js +2 -2
  87. package/dist/validation/view-predicates/index.d.ts +6 -6
  88. package/dist/validation/view-predicates/index.js +6 -6
  89. package/dist/validation/view-predicates/outgoing.d.ts +1 -1
  90. package/dist/validation/view-predicates/outgoing.js +8 -4
  91. package/dist/validation/view-predicates/{expanded-element.d.ts → relation-expr.d.ts} +1 -1
  92. package/dist/validation/view-predicates/relation-expr.js +39 -0
  93. package/dist/validation/view-predicates/relation-with.d.ts +1 -1
  94. package/dist/validation/view-predicates/relation-with.js +8 -5
  95. package/dist/views/likec4-views.d.ts +1 -0
  96. package/dist/views/likec4-views.js +23 -4
  97. package/dist/workspace/AstNodeDescriptionProvider.d.ts +1 -1
  98. package/dist/workspace/AstNodeDescriptionProvider.js +2 -3
  99. package/dist/workspace/IndexManager.d.ts +1 -1
  100. package/dist/workspace/IndexManager.js +5 -4
  101. package/dist/workspace/LangiumDocuments.d.ts +1 -1
  102. package/dist/workspace/LangiumDocuments.js +3 -5
  103. package/dist/workspace/ProjectsManager.d.ts +25 -7
  104. package/dist/workspace/ProjectsManager.js +76 -32
  105. package/dist/workspace/WorkspaceManager.d.ts +4 -5
  106. package/dist/workspace/WorkspaceManager.js +53 -20
  107. package/package.json +17 -13
  108. package/dist/validation/dynamic-view-rule.d.ts +0 -4
  109. package/dist/validation/dynamic-view-rule.js +0 -17
  110. package/dist/validation/view-predicates/element-with.js +0 -31
  111. package/dist/validation/view-predicates/expanded-element.js +0 -12
  112. package/dist/validation/view-predicates/expression-v2.d.ts +0 -5
  113. package/dist/validation/view-predicates/expression-v2.js +0 -83
@@ -1,22 +1,42 @@
1
1
  import type * as c4 from '@likec4/core';
2
2
  import { ast } from '../../ast';
3
- import { type Base } from './Base';
3
+ import type { WithExpressionV2 } from './FqnRefParser';
4
4
  export type WithPredicates = ReturnType<typeof PredicatesParser>;
5
- export declare function PredicatesParser<TBase extends Base>(B: TBase): {
5
+ export declare function PredicatesParser<TBase extends WithExpressionV2>(B: TBase): {
6
6
  new (...args: any[]): {
7
- parsePredicate(astNode: ast.Predicate): c4.Expression;
8
- parseElementPredicate(astNode: ast.ElementPredicate): c4.ElementPredicateExpression;
9
- parseElementExpressionsIterator(astNode: ast.ElementExpressionsIterator): c4.ElementExpression[];
10
- parseElementExpression(astNode: ast.ElementExpression): c4.ElementExpression;
11
- parseElementPredicateWhere(astNode: ast.ElementPredicateWhere): c4.ElementWhereExpr;
12
- parseElementPredicateWith(astNode: ast.ElementPredicateWith): c4.CustomElementExpr;
13
- parseRelationPredicate(astNode: ast.RelationPredicate): c4.RelationPredicateExpression;
14
- parseRelationPredicateWhere(astNode: ast.RelationPredicateWhere): c4.RelationWhereExpr;
15
- parseRelationPredicateWith(astNode: ast.RelationPredicateWith, relation: c4.RelationExpression | c4.RelationWhereExpr): c4.CustomRelationExpr;
16
- parseRelationExpression(astNode: ast.RelationExpression): c4.RelationExpression;
7
+ parsePredicate(astNode: ast.ExpressionV2): c4.ModelLayer.Expression;
8
+ parseElementPredicate(astNode: ast.FqnExprOrWith): c4.ModelLayer.AnyFqnExpr;
9
+ parseElementPredicateOrWhere(astNode: ast.FqnExprOrWhere): c4.ModelLayer.FqnExprOrWhere;
10
+ parseElementExpression(astNode: ast.FqnExpr): c4.ModelLayer.FqnExpr;
11
+ parseElementPredicateWhere(astNode: ast.FqnExprWhere): c4.ModelLayer.FqnExpr.Where;
12
+ parseElementPredicateWith(astNode: ast.FqnExprWith): c4.ModelLayer.FqnExpr.Custom;
13
+ parseRelationPredicate(astNode: ast.RelationExprOrWith): c4.ModelLayer.AnyRelationExpr;
14
+ parseRelationPredicateOrWhere(astNode: ast.RelationExprOrWhere): c4.ModelLayer.RelationExprOrWhere;
15
+ parseRelationPredicateWhere(astNode: ast.RelationExprWhere): c4.ModelLayer.RelationExpr.Where;
16
+ parseRelationPredicateWith(astNode: ast.RelationExprWith): c4.ModelLayer.RelationExpr.Custom;
17
+ parseRelationExpression(astNode: ast.RelationExpr): c4.ModelLayer.RelationExpr;
18
+ parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
19
+ parseExpressionV2(astNode: ast.ExpressionV2): c4.ExpressionV2;
20
+ parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
21
+ parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
22
+ parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
23
+ parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
24
+ parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
25
+ parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
26
+ parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
27
+ parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
28
+ parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
29
+ parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
30
+ parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
31
+ parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
17
32
  isValid: import("../../validation").IsValidFn;
18
33
  readonly services: import("../..").LikeC4Services;
19
34
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
35
+ readonly project: {
36
+ id: c4.ProjectId;
37
+ folder: c4;
38
+ config: Readonly<import("../../config").ProjectConfig>;
39
+ };
20
40
  resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
21
41
  getAstNodePath(node: c4): any;
22
42
  getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
@@ -30,5 +50,8 @@ export declare function PredicatesParser<TBase extends Base>(B: TBase): {
30
50
  }>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
31
51
  convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
32
52
  parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
53
+ parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
54
+ parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
55
+ parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
33
56
  };
34
57
  } & TBase;
@@ -1,296 +1,45 @@
1
- import { invariant, nonexhaustive } from "@likec4/core";
2
- import { isBoolean, isDefined, isTruthy } from "remeda";
3
- import { ast, parseAstOpacityProperty, parseAstSizeValue, toColor } from "../../ast.js";
4
- import { logWarnError } from "../../logger.js";
5
- import { elementRef } from "../../utils/elementRef.js";
6
- import { parseWhereClause } from "../model-parser-where.js";
7
- import { removeIndent } from "./Base.js";
1
+ import { nonexhaustive } from "@likec4/core";
2
+ import { ast } from "../../ast.js";
8
3
  export function PredicatesParser(B) {
9
4
  return class PredicatesParser extends B {
10
5
  parsePredicate(astNode) {
11
- if (ast.isElementPredicate(astNode)) {
12
- return this.parseElementPredicate(astNode);
13
- }
14
- if (ast.isRelationPredicate(astNode)) {
15
- return this.parseRelationPredicate(astNode);
16
- }
17
- nonexhaustive(astNode);
6
+ return this.parseExpressionV2(astNode);
18
7
  }
19
8
  parseElementPredicate(astNode) {
20
- if (ast.isElementPredicateWith(astNode)) {
21
- return this.parseElementPredicateWith(astNode);
9
+ if (ast.isFqnExprWith(astNode)) {
10
+ return this.parseFqnExprWith(astNode);
22
11
  }
23
- if (ast.isElementPredicateWhere(astNode)) {
24
- return this.parseElementPredicateWhere(astNode);
25
- }
26
- if (ast.isElementExpression(astNode)) {
27
- return this.parseElementExpression(astNode);
12
+ if (ast.isFqnExprOrWhere(astNode)) {
13
+ return this.parseFqnExprOrWhere(astNode);
28
14
  }
29
15
  nonexhaustive(astNode);
30
16
  }
31
- parseElementExpressionsIterator(astNode) {
32
- const exprs = [];
33
- let iter = astNode;
34
- while (iter) {
35
- try {
36
- if (iter.value) {
37
- exprs.unshift(this.parseElementExpression(iter.value));
38
- }
39
- } catch (e) {
40
- logWarnError(e);
41
- }
42
- iter = iter.prev;
43
- }
44
- return exprs;
17
+ parseElementPredicateOrWhere(astNode) {
18
+ return this.parseFqnExprOrWhere(astNode);
45
19
  }
46
20
  parseElementExpression(astNode) {
47
- if (ast.isWildcardExpression(astNode)) {
48
- return {
49
- wildcard: true
50
- };
51
- }
52
- if (ast.isElementKindExpression(astNode)) {
53
- invariant(astNode.kind?.ref, "ElementKindExpr kind is not resolved: " + astNode.$cstNode?.text);
54
- return {
55
- elementKind: astNode.kind.ref.name,
56
- isEqual: astNode.isEqual
57
- };
58
- }
59
- if (ast.isElementTagExpression(astNode)) {
60
- invariant(astNode.tag?.ref, "ElementTagExpr tag is not resolved: " + astNode.$cstNode?.text);
61
- let elementTag = astNode.tag.$refText;
62
- if (elementTag.startsWith("#")) {
63
- elementTag = elementTag.slice(1);
64
- }
65
- return {
66
- elementTag,
67
- isEqual: astNode.isEqual
68
- };
69
- }
70
- if (ast.isExpandElementExpression(astNode)) {
71
- const elementNode = elementRef(astNode.expand);
72
- invariant(elementNode, "Element not found " + astNode.expand.$cstNode?.text);
73
- const expanded = this.resolveFqn(elementNode);
74
- return {
75
- expanded
76
- };
77
- }
78
- if (ast.isElementDescedantsExpression(astNode)) {
79
- const elementNode = elementRef(astNode.parent);
80
- invariant(elementNode, "Element not found " + astNode.parent.$cstNode?.text);
81
- const element = this.resolveFqn(elementNode);
82
- return {
83
- element,
84
- isChildren: astNode.suffix === ".*",
85
- isDescendants: astNode.suffix === ".**"
86
- };
87
- }
88
- if (ast.isElementRef(astNode)) {
89
- const elementNode = elementRef(astNode);
90
- invariant(elementNode, "Element not found " + astNode.$cstNode?.text);
91
- const element = this.resolveFqn(elementNode);
92
- return {
93
- element
94
- };
95
- }
96
- nonexhaustive(astNode);
21
+ return this.parseFqnExpr(astNode);
97
22
  }
98
23
  parseElementPredicateWhere(astNode) {
99
- const expr = this.parseElementExpression(astNode.subject);
100
- return {
101
- where: {
102
- expr,
103
- condition: astNode.where ? parseWhereClause(astNode.where) : {
104
- kind: { neq: "--always-true--" }
105
- }
106
- }
107
- };
24
+ return this.parseFqnExprWhere(astNode);
108
25
  }
109
26
  parseElementPredicateWith(astNode) {
110
- const expr = this.parseElementPredicate(astNode.subject);
111
- const props = astNode.custom?.props ?? [];
112
- return props.reduce(
113
- (acc, prop) => {
114
- if (!this.isValid(prop)) {
115
- return acc;
116
- }
117
- if (ast.isNavigateToProperty(prop)) {
118
- const viewId = prop.value.view.$refText;
119
- if (isTruthy(viewId)) {
120
- acc.custom.navigateTo = viewId;
121
- }
122
- return acc;
123
- }
124
- if (ast.isElementStringProperty(prop)) {
125
- if (isDefined(prop.value)) {
126
- acc.custom[prop.key] = removeIndent(prop.value) || "";
127
- }
128
- return acc;
129
- }
130
- if (ast.isIconProperty(prop)) {
131
- const value = prop.libicon?.ref?.name ?? prop.value;
132
- if (isDefined(value)) {
133
- acc.custom[prop.key] = value;
134
- }
135
- return acc;
136
- }
137
- if (ast.isColorProperty(prop)) {
138
- const value = toColor(prop);
139
- if (isDefined(value)) {
140
- acc.custom[prop.key] = value;
141
- }
142
- return acc;
143
- }
144
- if (ast.isShapeProperty(prop)) {
145
- if (isDefined(prop.value)) {
146
- acc.custom[prop.key] = prop.value;
147
- }
148
- return acc;
149
- }
150
- if (ast.isBorderProperty(prop)) {
151
- if (isDefined(prop.value)) {
152
- acc.custom[prop.key] = prop.value;
153
- }
154
- return acc;
155
- }
156
- if (ast.isOpacityProperty(prop)) {
157
- if (isDefined(prop.value)) {
158
- acc.custom[prop.key] = parseAstOpacityProperty(prop);
159
- }
160
- return acc;
161
- }
162
- if (ast.isNotationProperty(prop)) {
163
- if (isTruthy(prop.value)) {
164
- acc.custom[prop.key] = removeIndent(prop.value);
165
- }
166
- return acc;
167
- }
168
- if (ast.isMultipleProperty(prop)) {
169
- if (isBoolean(prop.value)) {
170
- acc.custom[prop.key] = prop.value;
171
- }
172
- return acc;
173
- }
174
- if (ast.isShapeSizeProperty(prop)) {
175
- if (isTruthy(prop.value)) {
176
- acc.custom[prop.key] = parseAstSizeValue(prop);
177
- }
178
- return acc;
179
- }
180
- if (ast.isTextSizeProperty(prop)) {
181
- if (isTruthy(prop.value)) {
182
- acc.custom[prop.key] = parseAstSizeValue(prop);
183
- }
184
- return acc;
185
- }
186
- if (ast.isPaddingSizeProperty(prop)) {
187
- if (isTruthy(prop.value)) {
188
- acc.custom[prop.key] = parseAstSizeValue(prop);
189
- }
190
- return acc;
191
- }
192
- nonexhaustive(prop);
193
- },
194
- {
195
- custom: {
196
- expr
197
- }
198
- }
199
- );
27
+ return this.parseFqnExprWith(astNode);
200
28
  }
201
29
  parseRelationPredicate(astNode) {
202
- if (ast.isRelationPredicateWith(astNode)) {
203
- let relation = ast.isRelationPredicateWhere(astNode.subject) ? this.parseRelationPredicateWhere(astNode.subject) : this.parseRelationExpression(astNode.subject);
204
- return this.parseRelationPredicateWith(astNode, relation);
205
- }
206
- if (ast.isRelationPredicateWhere(astNode)) {
207
- return this.parseRelationPredicateWhere(astNode);
208
- }
209
- if (ast.isRelationExpression(astNode)) {
210
- return this.parseRelationExpression(astNode);
211
- }
212
- nonexhaustive(astNode);
30
+ return this.parseRelationExprOrWith(astNode);
31
+ }
32
+ parseRelationPredicateOrWhere(astNode) {
33
+ return this.parseRelationExprOrWhere(astNode);
213
34
  }
214
35
  parseRelationPredicateWhere(astNode) {
215
- const expr = this.parseRelationExpression(astNode.subject);
216
- return {
217
- where: {
218
- expr,
219
- condition: astNode.where ? parseWhereClause(astNode.where) : {
220
- kind: { neq: "--always-true--" }
221
- }
222
- }
223
- };
36
+ return this.parseRelationExprWhere(astNode);
224
37
  }
225
- parseRelationPredicateWith(astNode, relation) {
226
- const props = astNode.custom?.props ?? [];
227
- return props.reduce(
228
- (acc, prop) => {
229
- if (ast.isRelationStringProperty(prop) || ast.isNotationProperty(prop) || ast.isNotesProperty(prop)) {
230
- if (isDefined(prop.value)) {
231
- acc.customRelation[prop.key] = removeIndent(prop.value) ?? "";
232
- }
233
- return acc;
234
- }
235
- if (ast.isArrowProperty(prop)) {
236
- if (isTruthy(prop.value)) {
237
- acc.customRelation[prop.key] = prop.value;
238
- }
239
- return acc;
240
- }
241
- if (ast.isColorProperty(prop)) {
242
- const value = toColor(prop);
243
- if (isTruthy(value)) {
244
- acc.customRelation[prop.key] = value;
245
- }
246
- return acc;
247
- }
248
- if (ast.isLineProperty(prop)) {
249
- if (isTruthy(prop.value)) {
250
- acc.customRelation[prop.key] = prop.value;
251
- }
252
- return acc;
253
- }
254
- if (ast.isRelationNavigateToProperty(prop)) {
255
- const viewId = prop.value.view.ref?.name;
256
- if (isTruthy(viewId)) {
257
- acc.customRelation.navigateTo = viewId;
258
- }
259
- return acc;
260
- }
261
- nonexhaustive(prop);
262
- },
263
- {
264
- customRelation: {
265
- relation
266
- }
267
- }
268
- );
38
+ parseRelationPredicateWith(astNode) {
39
+ return this.parseRelationExprWith(astNode);
269
40
  }
270
41
  parseRelationExpression(astNode) {
271
- if (ast.isDirectedRelationExpression(astNode)) {
272
- return {
273
- source: this.parseElementExpression(astNode.source.from),
274
- target: this.parseElementExpression(astNode.target),
275
- isBidirectional: astNode.source.isBidirectional
276
- };
277
- }
278
- if (ast.isInOutRelationExpression(astNode)) {
279
- return {
280
- inout: this.parseElementExpression(astNode.inout.to)
281
- };
282
- }
283
- if (ast.isOutgoingRelationExpression(astNode)) {
284
- return {
285
- outgoing: this.parseElementExpression(astNode.from)
286
- };
287
- }
288
- if (ast.isIncomingRelationExpression(astNode)) {
289
- return {
290
- incoming: this.parseElementExpression(astNode.to)
291
- };
292
- }
293
- nonexhaustive(astNode);
42
+ return this.parseRelationExpr(astNode);
294
43
  }
295
44
  };
296
45
  }
@@ -10,6 +10,11 @@ export declare function SpecificationParser<TBase extends Base>(B: TBase): {
10
10
  isValid: import("../../validation").IsValidFn;
11
11
  readonly services: import("../..").LikeC4Services;
12
12
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
13
+ readonly project: {
14
+ id: c4.ProjectId;
15
+ folder: c4;
16
+ config: Readonly<import("../../config").ProjectConfig>;
17
+ };
13
18
  resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
14
19
  getAstNodePath(node: c4): any;
15
20
  getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
@@ -23,5 +28,8 @@ export declare function SpecificationParser<TBase extends Base>(B: TBase): {
23
28
  }>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
24
29
  convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
25
30
  parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
31
+ parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
32
+ parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
33
+ parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
26
34
  };
27
35
  } & TBase;
@@ -1,5 +1,5 @@
1
1
  import { filter, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
2
- import { ast, toElementStyle, toRelationshipStyleExcludeDefaults } from "../../ast.js";
2
+ import { ast, toRelationshipStyleExcludeDefaults } from "../../ast.js";
3
3
  import { logger, logWarnError } from "../../logger.js";
4
4
  import { removeIndent } from "./Base.js";
5
5
  export function SpecificationParser(B) {
@@ -25,7 +25,7 @@ export function SpecificationParser(B) {
25
25
  logger.warn(`Element kind "${kindName}" is already defined`);
26
26
  continue;
27
27
  }
28
- const style = props.find(ast.isElementStyleProperty);
28
+ const style = this.parseElementStyle(props.find(ast.isElementStyleProperty));
29
29
  const bodyProps = pipe(
30
30
  props.filter(ast.isSpecificationElementStringProperty) ?? [],
31
31
  filter((p) => this.isValid(p) && isNonNullish(p.value)),
@@ -33,9 +33,7 @@ export function SpecificationParser(B) {
33
33
  );
34
34
  c4Specification.elements[kindName] = {
35
35
  ...bodyProps,
36
- style: {
37
- ...toElementStyle(style?.props, this.isValid)
38
- }
36
+ style
39
37
  };
40
38
  } catch (e) {
41
39
  logWarnError(e);
@@ -101,7 +99,7 @@ export function SpecificationParser(B) {
101
99
  if (!isTruthy(kindName)) {
102
100
  throw new Error("DeploymentNodeKind name is not resolved");
103
101
  }
104
- const style = props.find(ast.isElementStyleProperty);
102
+ const style = this.parseElementStyle(props.find(ast.isElementStyleProperty));
105
103
  const bodyProps = pipe(
106
104
  props.filter(ast.isSpecificationElementStringProperty) ?? [],
107
105
  filter((p) => this.isValid(p) && isNonNullish(p.value)),
@@ -110,9 +108,7 @@ export function SpecificationParser(B) {
110
108
  return {
111
109
  [kindName]: {
112
110
  ...bodyProps,
113
- style: {
114
- ...toElementStyle(style?.props, this.isValid)
115
- }
111
+ style
116
112
  }
117
113
  };
118
114
  }
@@ -1,5 +1,5 @@
1
1
  import type * as c4 from '@likec4/core';
2
- import { ast, type ParsedAstDynamicView, type ParsedAstElementView } from '../../ast';
2
+ import { type ParsedAstDynamicView, type ParsedAstElementView, ast } from '../../ast';
3
3
  import type { NotationProperty } from '../../generated/ast';
4
4
  import type { WithDeploymentView } from './DeploymentViewParser';
5
5
  import type { WithPredicates } from './PredicatesParser';
@@ -14,26 +14,46 @@ export declare function ViewsParser<TBase extends WithPredicates & WithDeploymen
14
14
  parseViewRuleStyleOrGlobalRef(astRule: ast.ViewRuleStyleOrGlobalRef): c4.ViewRuleStyleOrGlobalRef;
15
15
  parseViewRuleGroup(astNode: ast.ViewRuleGroup): c4.ViewRuleGroup;
16
16
  parseViewRuleStyle(astRule: ast.ViewRuleStyle | ast.GlobalStyle): c4.ViewRuleStyle;
17
- parseRuleStyle(styleProperties: ast.StyleProperty[], elementExpressionsIterator: ast.ElementExpressionsIterator, notationProperty?: NotationProperty): c4.ViewRuleStyle;
17
+ parseRuleStyle(styleProperties: ast.StyleProperty[], elementExpressionsIterator: ast.FqnExpressions, notationProperty?: NotationProperty): c4.ViewRuleStyle;
18
18
  parseViewRuleGlobalStyle(astRule: ast.ViewRuleGlobalStyle): c4.ViewRuleGlobalStyle;
19
19
  parseDynamicElementView(astNode: ast.DynamicView, additionalStyles: c4.ViewRuleStyleOrGlobalRef[]): ParsedAstDynamicView;
20
20
  parseDynamicViewRule(astRule: ast.DynamicViewRule): c4.DynamicViewRule;
21
21
  parseDynamicViewIncludePredicate(astRule: ast.DynamicViewIncludePredicate): c4.DynamicViewIncludeRule;
22
22
  parseDynamicParallelSteps(node: ast.DynamicViewParallelSteps): c4.DynamicViewParallelSteps;
23
23
  parseDynamicStep(node: ast.DynamicViewStep): c4.DynamicViewStep;
24
- parsePredicate(astNode: ast.Predicate): c4.Expression;
25
- parseElementPredicate(astNode: ast.ElementPredicate): c4.ElementPredicateExpression;
26
- parseElementExpressionsIterator(astNode: ast.ElementExpressionsIterator): c4.ElementExpression[];
27
- parseElementExpression(astNode: ast.ElementExpression): c4.ElementExpression;
28
- parseElementPredicateWhere(astNode: ast.ElementPredicateWhere): c4.ElementWhereExpr;
29
- parseElementPredicateWith(astNode: ast.ElementPredicateWith): c4.CustomElementExpr;
30
- parseRelationPredicate(astNode: ast.RelationPredicate): c4.RelationPredicateExpression;
31
- parseRelationPredicateWhere(astNode: ast.RelationPredicateWhere): c4.RelationWhereExpr;
32
- parseRelationPredicateWith(astNode: ast.RelationPredicateWith, relation: c4.RelationExpression | c4.RelationWhereExpr): c4.CustomRelationExpr;
33
- parseRelationExpression(astNode: ast.RelationExpression): c4.RelationExpression;
24
+ parsePredicate(astNode: ast.ExpressionV2): c4.ModelLayer.Expression;
25
+ parseElementPredicate(astNode: ast.FqnExprOrWith): c4.ModelLayer.AnyFqnExpr;
26
+ parseElementPredicateOrWhere(astNode: ast.FqnExprOrWhere): c4.ModelLayer.FqnExprOrWhere;
27
+ parseElementExpression(astNode: ast.FqnExpr): c4.ModelLayer.FqnExpr;
28
+ parseElementPredicateWhere(astNode: ast.FqnExprWhere): c4.ModelLayer.FqnExpr.Where;
29
+ parseElementPredicateWith(astNode: ast.FqnExprWith): c4.ModelLayer.FqnExpr.Custom;
30
+ parseRelationPredicate(astNode: ast.RelationExprOrWith): c4.ModelLayer.AnyRelationExpr;
31
+ parseRelationPredicateOrWhere(astNode: ast.RelationExprOrWhere): c4.ModelLayer.RelationExprOrWhere;
32
+ parseRelationPredicateWhere(astNode: ast.RelationExprWhere): c4.ModelLayer.RelationExpr.Where;
33
+ parseRelationPredicateWith(astNode: ast.RelationExprWith): c4.ModelLayer.RelationExpr.Custom;
34
+ parseRelationExpression(astNode: ast.RelationExpr): c4.ModelLayer.RelationExpr;
35
+ parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
36
+ parseExpressionV2(astNode: ast.ExpressionV2): c4.ExpressionV2;
37
+ parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
38
+ parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
39
+ parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
40
+ parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
41
+ parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
42
+ parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
43
+ parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
44
+ parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
45
+ parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
46
+ parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
47
+ parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
48
+ parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
34
49
  isValid: import("../../validation").IsValidFn;
35
50
  readonly services: import("../..").LikeC4Services;
36
51
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
52
+ readonly project: {
53
+ id: c4.ProjectId;
54
+ folder: c4;
55
+ config: Readonly<import("../../config").ProjectConfig>;
56
+ };
37
57
  resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
38
58
  getAstNodePath(node: c4): any;
39
59
  getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
@@ -47,21 +67,18 @@ export declare function ViewsParser<TBase extends WithPredicates & WithDeploymen
47
67
  }>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
48
68
  convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
49
69
  parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
70
+ parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
71
+ parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
72
+ parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
50
73
  parseDeploymentView(astNode: ast.DeploymentView): import("../../ast").ParsedAstDeploymentView;
51
74
  parseDeploymentViewRule(astRule: ast.DeploymentViewRule): c4.DeploymentViewRule;
52
75
  parseDeploymentViewRulePredicate(astRule: ast.DeploymentViewRulePredicate): c4.DeploymentViewRulePredicate;
53
76
  parseDeploymentViewRuleStyle(astRule: ast.DeploymentViewRuleStyle): c4.DeploymentViewRuleStyle;
54
- parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
55
- parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
56
- parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
57
- parseElementWhereExpr(astNode: ast.ElementPredicateWhereV2): c4.RelationExpr;
58
- parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
59
- parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
60
- parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
61
77
  parseDeployment(): void;
62
78
  parseDeploymentNode(astNode: ast.DeploymentNode): import("../../ast").ParsedAstDeployment.Node;
63
79
  parseDeployedInstance(astNode: ast.DeployedInstance): import("../../ast").ParsedAstDeployment.Instance;
64
80
  parseExtendDeployment(astNode: ast.ExtendDeployment): import("../../ast").ParsedAstExtend | null;
81
+ _resolveDeploymentRelationSource(node: ast.DeploymentRelation): c4;
65
82
  parseDeploymentRelation(astNode: ast.DeploymentRelation): import("../../ast").ParsedAstDeploymentRelation;
66
83
  };
67
84
  } & TBase;
@@ -1,10 +1,9 @@
1
- import { invariant, isNonEmptyArray, nonexhaustive } from "@likec4/core";
1
+ import { invariant, isNonEmptyArray, ModelLayer, nonexhaustive } from "@likec4/core";
2
2
  import { isArray, isDefined, isNonNullish, isTruthy } from "remeda";
3
3
  import {
4
4
  ast,
5
5
  toAutoLayout,
6
6
  toColor,
7
- toElementStyle,
8
7
  ViewOps
9
8
  } from "../../ast.js";
10
9
  import { logger, logWarnError } from "../../logger.js";
@@ -128,12 +127,13 @@ export function ViewsParser(B) {
128
127
  }
129
128
  parseViewRulePredicate(astNode) {
130
129
  const exprs = [];
131
- let predicate = astNode.predicates;
130
+ let predicate = astNode.exprs;
132
131
  while (predicate) {
133
132
  const { value, prev } = predicate;
134
133
  try {
135
134
  if (isTruthy(value) && this.isValid(value)) {
136
- exprs.unshift(this.parsePredicate(value));
135
+ const expr = this.parsePredicate(value);
136
+ exprs.unshift(expr);
137
137
  }
138
138
  } catch (e) {
139
139
  logWarnError(e);
@@ -143,7 +143,7 @@ export function ViewsParser(B) {
143
143
  }
144
144
  predicate = prev;
145
145
  }
146
- return ast.isIncludePredicate(astNode) ? { include: exprs } : { exclude: exprs };
146
+ return astNode.isInclude ? { include: exprs } : { exclude: exprs };
147
147
  }
148
148
  parseViewRuleGlobalPredicateRef(astRule) {
149
149
  return {
@@ -182,19 +182,21 @@ export function ViewsParser(B) {
182
182
  return {
183
183
  title: toSingleLine(astNode.title) ?? null,
184
184
  groupRules,
185
- ...toElementStyle(astNode.props, this.isValid)
185
+ ...this.parseStyleProps(astNode.props)
186
186
  };
187
187
  }
188
188
  parseViewRuleStyle(astRule) {
189
189
  const styleProps = astRule.props.filter(ast.isStyleProperty);
190
- const targets = astRule.target;
190
+ const targets = astRule.targets;
191
191
  const notation = astRule.props.find(ast.isNotationProperty);
192
192
  return this.parseRuleStyle(styleProps, targets, notation);
193
193
  }
194
194
  parseRuleStyle(styleProperties, elementExpressionsIterator, notationProperty) {
195
- const styleProps = toElementStyle(styleProperties, this.isValid);
195
+ const styleProps = this.parseStyleProps(styleProperties);
196
196
  const notation = removeIndent(notationProperty?.value);
197
- const targets = this.parseElementExpressionsIterator(elementExpressionsIterator);
197
+ const targets = this.parseFqnExpressions(elementExpressionsIterator).filter(
198
+ (e) => ModelLayer.Expression.isFqnExpr(e)
199
+ );
198
200
  return {
199
201
  targets,
200
202
  ...notation && { notation },
@@ -280,12 +282,14 @@ export function ViewsParser(B) {
280
282
  }
281
283
  parseDynamicViewIncludePredicate(astRule) {
282
284
  const include = [];
283
- let iter = astRule.predicates;
285
+ let iter = astRule.exprs;
284
286
  while (iter) {
285
287
  try {
286
288
  if (isNonNullish(iter.value) && this.isValid(iter.value)) {
287
- const c4expr = this.parseElementPredicate(iter.value);
288
- include.unshift(c4expr);
289
+ if (ast.isFqnExprOrWith(iter.value)) {
290
+ const c4expr = this.parseElementPredicate(iter.value);
291
+ include.unshift(c4expr);
292
+ }
289
293
  }
290
294
  } catch (e) {
291
295
  logWarnError(e);
@@ -1,6 +1,6 @@
1
1
  import { type Fqn, type NonEmptyArray, type ViewChange } from '@likec4/core';
2
2
  import { type Range, TextEdit } from 'vscode-languageserver-types';
3
- import { ast, type ParsedAstView, type ParsedLikeC4LangiumDocument } from '../ast';
3
+ import { type ParsedAstView, type ParsedLikeC4LangiumDocument, ast } from '../ast';
4
4
  import type { LikeC4Services } from '../module';
5
5
  type ChangeElementStyleArg = {
6
6
  view: ParsedAstView;
@@ -9,7 +9,7 @@ type ChangeElementStyleArg = {
9
9
  targets: NonEmptyArray<Fqn>;
10
10
  style: ViewChange.ChangeElementStyle['style'];
11
11
  };
12
- export declare function changeElementStyle(services: LikeC4Services, { view, viewAst, targets, style }: ChangeElementStyleArg): {
12
+ export declare function changeElementStyle(services: LikeC4Services, { view, viewAst, targets, style, }: ChangeElementStyleArg): {
13
13
  modifiedRange: Range;
14
14
  edits: TextEdit[];
15
15
  };