@likec4/language-server 1.27.2 → 1.28.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.
Files changed (111) 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 +2130 -2127
  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 +134 -306
  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 +15 -11
  49. package/dist/model-change/changeElementStyle.d.ts +2 -2
  50. package/dist/model-change/changeElementStyle.js +2 -1
  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/workspace/AstNodeDescriptionProvider.d.ts +1 -1
  96. package/dist/workspace/AstNodeDescriptionProvider.js +2 -3
  97. package/dist/workspace/IndexManager.d.ts +1 -1
  98. package/dist/workspace/IndexManager.js +5 -4
  99. package/dist/workspace/LangiumDocuments.d.ts +1 -1
  100. package/dist/workspace/LangiumDocuments.js +3 -5
  101. package/dist/workspace/ProjectsManager.d.ts +25 -7
  102. package/dist/workspace/ProjectsManager.js +76 -32
  103. package/dist/workspace/WorkspaceManager.d.ts +4 -5
  104. package/dist/workspace/WorkspaceManager.js +53 -20
  105. package/package.json +12 -10
  106. package/dist/validation/dynamic-view-rule.d.ts +0 -4
  107. package/dist/validation/dynamic-view-rule.js +0 -17
  108. package/dist/validation/view-predicates/element-with.js +0 -31
  109. package/dist/validation/view-predicates/expanded-element.js +0 -12
  110. package/dist/validation/view-predicates/expression-v2.d.ts +0 -5
  111. package/dist/validation/view-predicates/expression-v2.js +0 -83
@@ -1,7 +1,26 @@
1
- import { isNonEmptyArray } from "@likec4/core";
2
- import { filter, flatMap, fromEntries, isEmpty, isNonNullish, isTruthy, map, pipe, unique } from "remeda";
1
+ import { GlobalFqn, isNonEmptyArray, nonexhaustive, nonNullable } from "@likec4/core";
2
+ import {
3
+ filter,
4
+ flatMap,
5
+ fromEntries,
6
+ isArray,
7
+ isBoolean,
8
+ isEmpty,
9
+ isNonNullish,
10
+ isTruthy,
11
+ map,
12
+ pipe,
13
+ unique
14
+ } from "remeda";
3
15
  import stripIndent from "strip-indent";
4
- import { ast } from "../../ast.js";
16
+ import { hasLeadingSlash, hasProtocol, isRelative, joinRelativeURL, joinURL } from "ufo";
17
+ import {
18
+ ast,
19
+ parseAstOpacityProperty,
20
+ parseAstSizeValue,
21
+ toColor
22
+ } from "../../ast.js";
23
+ import { projectIdFrom } from "../../utils/index.js";
5
24
  import { readStrictFqn } from "../../utils/elementRef.js";
6
25
  import { checksFromDiagnostics } from "../../validation/index.js";
7
26
  export function toSingleLine(str) {
@@ -17,7 +36,18 @@ export class BaseParser {
17
36
  this.isValid = checksFromDiagnostics(doc).isValid;
18
37
  }
19
38
  isValid;
39
+ get project() {
40
+ return this.services.shared.workspace.ProjectsManager.getProject(this.doc);
41
+ }
20
42
  resolveFqn(node) {
43
+ if (ast.isImported(node)) {
44
+ const project = projectIdFrom(node);
45
+ const fqn = this.resolveFqn(
46
+ nonNullable(node.imported.ref, `FqnRef is empty of imported: ${node.$cstNode?.text}`)
47
+ );
48
+ this.doc.c4Imports.set(project, fqn);
49
+ return GlobalFqn(project, fqn);
50
+ }
21
51
  if (ast.isExtendElement(node)) {
22
52
  return readStrictFqn(node.element);
23
53
  }
@@ -96,4 +126,109 @@ export class BaseParser {
96
126
  })
97
127
  );
98
128
  }
129
+ parseIconProperty(prop) {
130
+ if (!prop || !this.isValid(prop)) {
131
+ return void 0;
132
+ }
133
+ const { libicon, value } = prop;
134
+ switch (true) {
135
+ case !!libicon: {
136
+ return libicon.ref?.name;
137
+ }
138
+ case (value && hasProtocol(value)): {
139
+ return value;
140
+ }
141
+ case (value && isRelative(value)): {
142
+ return joinRelativeURL(this.doc.uri.toString(), "../", value);
143
+ }
144
+ case (value && hasLeadingSlash(value)): {
145
+ return joinURL(this.project.folder.toString(), value);
146
+ }
147
+ default: {
148
+ return void 0;
149
+ }
150
+ }
151
+ }
152
+ parseElementStyle(elementProps) {
153
+ if (!elementProps) {
154
+ return {};
155
+ }
156
+ if (isArray(elementProps)) {
157
+ const style = this.parseStyleProps(elementProps?.find(ast.isElementStyleProperty)?.props);
158
+ const iconProp = this.parseIconProperty(elementProps?.find(ast.isIconProperty));
159
+ if (iconProp) {
160
+ style.icon = iconProp;
161
+ }
162
+ return style;
163
+ }
164
+ return this.parseStyleProps(elementProps.props);
165
+ }
166
+ parseStyleProps(styleProps) {
167
+ const result = {};
168
+ if (!styleProps || styleProps.length === 0) {
169
+ return result;
170
+ }
171
+ for (const prop of styleProps) {
172
+ if (!this.isValid(prop)) {
173
+ continue;
174
+ }
175
+ switch (true) {
176
+ case ast.isBorderProperty(prop): {
177
+ if (isTruthy(prop.value)) {
178
+ result.border = prop.value;
179
+ }
180
+ break;
181
+ }
182
+ case ast.isColorProperty(prop): {
183
+ const color = toColor(prop);
184
+ if (isTruthy(color)) {
185
+ result.color = color;
186
+ }
187
+ break;
188
+ }
189
+ case ast.isShapeProperty(prop): {
190
+ if (isTruthy(prop.value)) {
191
+ result.shape = prop.value;
192
+ }
193
+ break;
194
+ }
195
+ case ast.isIconProperty(prop): {
196
+ const icon = this.parseIconProperty(prop);
197
+ if (isTruthy(icon)) {
198
+ result.icon = icon;
199
+ }
200
+ break;
201
+ }
202
+ case ast.isOpacityProperty(prop): {
203
+ result.opacity = parseAstOpacityProperty(prop);
204
+ break;
205
+ }
206
+ case ast.isMultipleProperty(prop): {
207
+ result.multiple = isBoolean(prop.value) ? prop.value : false;
208
+ break;
209
+ }
210
+ case ast.isShapeSizeProperty(prop): {
211
+ if (isTruthy(prop.value)) {
212
+ result.size = parseAstSizeValue(prop);
213
+ }
214
+ break;
215
+ }
216
+ case ast.isPaddingSizeProperty(prop): {
217
+ if (isTruthy(prop.value)) {
218
+ result.padding = parseAstSizeValue(prop);
219
+ }
220
+ break;
221
+ }
222
+ case ast.isTextSizeProperty(prop): {
223
+ if (isTruthy(prop.value)) {
224
+ result.textSize = parseAstSizeValue(prop);
225
+ }
226
+ break;
227
+ }
228
+ default:
229
+ nonexhaustive(prop);
230
+ }
231
+ }
232
+ return result;
233
+ }
99
234
  }
@@ -1,4 +1,5 @@
1
1
  import type * as c4 from '@likec4/core';
2
+ import { FqnRef } from '@likec4/core';
2
3
  import { type ParsedAstDeployment, type ParsedAstDeploymentRelation, type ParsedAstExtend, ast } from '../../ast';
3
4
  import type { WithExpressionV2 } from './FqnRefParser';
4
5
  export type WithDeploymentModel = ReturnType<typeof DeploymentModelParser>;
@@ -8,17 +9,30 @@ export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B:
8
9
  parseDeploymentNode(astNode: ast.DeploymentNode): ParsedAstDeployment.Node;
9
10
  parseDeployedInstance(astNode: ast.DeployedInstance): ParsedAstDeployment.Instance;
10
11
  parseExtendDeployment(astNode: ast.ExtendDeployment): ParsedAstExtend | null;
12
+ _resolveDeploymentRelationSource(node: ast.DeploymentRelation): FqnRef;
11
13
  parseDeploymentRelation(astNode: ast.DeploymentRelation): ParsedAstDeploymentRelation;
12
14
  parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
15
+ parseExpressionV2(astNode: ast.ExpressionV2): c4.ExpressionV2;
16
+ parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
17
+ parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
18
+ parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
19
+ parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
13
20
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
14
21
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
15
- parseElementWhereExpr(astNode: ast.ElementPredicateWhereV2): c4.RelationExpr;
16
22
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
17
- parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
23
+ parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
24
+ parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
25
+ parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
26
+ parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
18
27
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
19
28
  isValid: import("../../validation").IsValidFn;
20
29
  readonly services: import("../..").LikeC4Services;
21
30
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
31
+ readonly project: {
32
+ id: c4.ProjectId;
33
+ folder: c4;
34
+ config: Readonly<import("../../config").ProjectConfig>;
35
+ };
22
36
  resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
23
37
  getAstNodePath(node: c4): any;
24
38
  getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
@@ -32,5 +46,8 @@ export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B:
32
46
  }>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
33
47
  convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
34
48
  parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
49
+ parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
50
+ parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
51
+ parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
35
52
  };
36
53
  } & TBase;
@@ -1,12 +1,10 @@
1
- import { FqnRef, isNonEmptyArray, LinkedList, nameFromFqn, nonexhaustive, nonNullable } from "@likec4/core";
2
- import { filter, first, isEmpty, isTruthy, map, mapToObj, pipe } from "remeda";
1
+ import { FqnRef, invariant, isNonEmptyArray, LinkedList, nameFromFqn, nonexhaustive, nonNullable } from "@likec4/core";
2
+ import { filter, first, isDefined, isEmpty, isTruthy, map, mapToObj, pipe } from "remeda";
3
3
  import {
4
4
  ast,
5
- toElementStyle,
6
5
  toRelationshipStyleExcludeDefaults
7
6
  } from "../../ast.js";
8
7
  import { logWarnError } from "../../logger.js";
9
- import { elementRef } from "../../utils/elementRef.js";
10
8
  import { stringHash } from "../../utils/stringHash.js";
11
9
  import { removeIndent, toSingleLine } from "./Base.js";
12
10
  function* streamDeploymentModel(doc) {
@@ -20,10 +18,6 @@ function* streamDeploymentModel(doc) {
20
18
  relations.push(el);
21
19
  continue;
22
20
  }
23
- if (ast.isDeployedInstance(el)) {
24
- yield el;
25
- continue;
26
- }
27
21
  if (el.body && el.body.elements.length > 0) {
28
22
  for (const child of el.body.elements) {
29
23
  traverseStack.push(child);
@@ -74,8 +68,7 @@ export function DeploymentModelParser(B) {
74
68
  const id = this.resolveFqn(astNode);
75
69
  const kind = nonNullable(astNode.kind.ref, "DeploymentKind not resolved").name;
76
70
  const tags = this.convertTags(astNode.body);
77
- const stylePropsAst = astNode.body?.props.find(ast.isElementStyleProperty)?.props;
78
- const style = toElementStyle(stylePropsAst, isValid);
71
+ const style = this.parseElementStyle(astNode.body?.props);
79
72
  const metadata = this.getMetadata(astNode.body?.props.find(ast.isMetadataProperty));
80
73
  const bodyProps = pipe(
81
74
  astNode.body?.props ?? [],
@@ -87,13 +80,6 @@ export function DeploymentModelParser(B) {
87
80
  const description = removeIndent(bodyProps.description);
88
81
  const technology = toSingleLine(bodyProps.technology);
89
82
  const links = this.convertLinks(astNode.body);
90
- const iconProp = astNode.body?.props.find(ast.isIconProperty);
91
- if (iconProp && isValid(iconProp)) {
92
- const value = iconProp.libicon?.ref?.name ?? iconProp.value;
93
- if (isTruthy(value)) {
94
- style.icon = value;
95
- }
96
- }
97
83
  return {
98
84
  id,
99
85
  kind,
@@ -109,10 +95,10 @@ export function DeploymentModelParser(B) {
109
95
  parseDeployedInstance(astNode) {
110
96
  const isValid = this.isValid;
111
97
  const id = this.resolveFqn(astNode);
112
- const element = this.resolveFqn(nonNullable(elementRef(astNode.element), "DeployedInstance element not found"));
98
+ const target = this.parseFqnRef(astNode.target.modelElement);
99
+ invariant(FqnRef.isModelRef(target) || FqnRef.isImportRef(target), "Target must be a model reference");
113
100
  const tags = this.convertTags(astNode.body);
114
- const stylePropsAst = astNode.body?.props.find(ast.isElementStyleProperty)?.props;
115
- const style = toElementStyle(stylePropsAst, isValid);
101
+ const style = this.parseElementStyle(astNode.body?.props);
116
102
  const metadata = this.getMetadata(astNode.body?.props.find(ast.isMetadataProperty));
117
103
  const bodyProps = pipe(
118
104
  astNode.body?.props ?? [],
@@ -124,16 +110,9 @@ export function DeploymentModelParser(B) {
124
110
  const description = removeIndent(bodyProps.description);
125
111
  const technology = toSingleLine(bodyProps.technology);
126
112
  const links = this.convertLinks(astNode.body);
127
- const iconProp = astNode.body?.props.find(ast.isIconProperty);
128
- if (iconProp && isValid(iconProp)) {
129
- const value = iconProp.libicon?.ref?.name ?? iconProp.value;
130
- if (isTruthy(value)) {
131
- style.icon = value;
132
- }
133
- }
134
113
  return {
135
114
  id,
136
- element,
115
+ element: target,
137
116
  ...metadata && { metadata },
138
117
  ...title && { title },
139
118
  ...tags && { tags },
@@ -163,10 +142,21 @@ export function DeploymentModelParser(B) {
163
142
  ...links && isNonEmptyArray(links) && { links }
164
143
  };
165
144
  }
145
+ _resolveDeploymentRelationSource(node) {
146
+ if (isDefined(node.source)) {
147
+ return this.parseFqnRef(node.source);
148
+ }
149
+ if (node.$container.$type === "DeploymentNodeBody" || node.$container.$type === "DeployedInstanceBody") {
150
+ return {
151
+ deployment: this.resolveFqn(node.$container.$container)
152
+ };
153
+ }
154
+ throw new Error("RelationRefError: Invalid container for sourceless relation");
155
+ }
166
156
  parseDeploymentRelation(astNode) {
167
157
  const isValid = this.isValid;
168
158
  const astPath = this.getAstNodePath(astNode);
169
- const source = FqnRef.toDeploymentRef(this.parseFqnRef(astNode.source));
159
+ const source = FqnRef.toDeploymentRef(this._resolveDeploymentRelationSource(astNode));
170
160
  const target = FqnRef.toDeploymentRef(this.parseFqnRef(astNode.target));
171
161
  const tags = this.convertTags(astNode) ?? this.convertTags(astNode.body);
172
162
  const links = this.convertLinks(astNode.body);
@@ -10,15 +10,27 @@ export declare function DeploymentViewParser<TBase extends WithExpressionV2 & Wi
10
10
  parseDeploymentViewRulePredicate(astRule: ast.DeploymentViewRulePredicate): c4.DeploymentViewRulePredicate;
11
11
  parseDeploymentViewRuleStyle(astRule: ast.DeploymentViewRuleStyle): c4.DeploymentViewRuleStyle;
12
12
  parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
13
+ parseExpressionV2(astNode: ast.ExpressionV2): c4.ExpressionV2;
14
+ parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
15
+ parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
16
+ parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
17
+ parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
13
18
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
14
19
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
15
- parseElementWhereExpr(astNode: ast.ElementPredicateWhereV2): c4.RelationExpr;
16
20
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
17
- parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
21
+ parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
22
+ parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
23
+ parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
24
+ parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
18
25
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
19
26
  isValid: import("../../validation").IsValidFn;
20
27
  readonly services: import("../..").LikeC4Services;
21
28
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
29
+ readonly project: {
30
+ id: c4.ProjectId;
31
+ folder: c4;
32
+ config: Readonly<import("../../config").ProjectConfig>;
33
+ };
22
34
  resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
23
35
  getAstNodePath(node: c4): any;
24
36
  getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
@@ -32,10 +44,14 @@ export declare function DeploymentViewParser<TBase extends WithExpressionV2 & Wi
32
44
  }>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
33
45
  convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
34
46
  parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
47
+ parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
48
+ parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
49
+ parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
35
50
  parseDeployment(): void;
36
51
  parseDeploymentNode(astNode: ast.DeploymentNode): import("../../ast").ParsedAstDeployment.Node;
37
52
  parseDeployedInstance(astNode: ast.DeployedInstance): import("../../ast").ParsedAstDeployment.Instance;
38
53
  parseExtendDeployment(astNode: ast.ExtendDeployment): import("../../ast").ParsedAstExtend | null;
54
+ _resolveDeploymentRelationSource(node: ast.DeploymentRelation): c4;
39
55
  parseDeploymentRelation(astNode: ast.DeploymentRelation): import("../../ast").ParsedAstDeploymentRelation;
40
56
  };
41
57
  } & TBase;
@@ -1,6 +1,6 @@
1
1
  import { invariant, isNonEmptyArray, nonexhaustive } from "@likec4/core";
2
2
  import { isNonNullish } from "remeda";
3
- import { ast, toAutoLayout, toElementStyle, ViewOps } from "../../ast.js";
3
+ import { ast, toAutoLayout, ViewOps } from "../../ast.js";
4
4
  import { logWarnError } from "../../logger.js";
5
5
  import { stringHash } from "../../utils/index.js";
6
6
  import { parseViewManualLayout } from "../../view-utils/manual-layout.js";
@@ -63,22 +63,7 @@ export function DeploymentViewParser(B) {
63
63
  try {
64
64
  const expr = iterator.value;
65
65
  if (isNonNullish(expr) && this.isValid(expr)) {
66
- switch (true) {
67
- case ast.isFqnExpr(expr):
68
- exprs.unshift(this.parseFqnExpr(expr));
69
- break;
70
- case ast.isElementPredicateWhereV2(expr):
71
- exprs.unshift(this.parseElementWhereExpr(expr));
72
- break;
73
- case ast.isRelationExpr(expr):
74
- exprs.unshift(this.parseRelationExpr(expr));
75
- break;
76
- case ast.isRelationPredicateWhereV2(expr):
77
- exprs.unshift(this.parseRelationWhereExpr(expr));
78
- break;
79
- default:
80
- nonexhaustive(expr);
81
- }
66
+ exprs.unshift(this.parseExpressionV2(expr));
82
67
  }
83
68
  } catch (e) {
84
69
  logWarnError(e);
@@ -88,16 +73,13 @@ export function DeploymentViewParser(B) {
88
73
  return astRule.isInclude ? { include: exprs } : { exclude: exprs };
89
74
  }
90
75
  parseDeploymentViewRuleStyle(astRule) {
91
- const styleProps = astRule.props.filter(ast.isStyleProperty);
92
- const notationProperty = astRule.props.find(ast.isNotationProperty);
93
- const notation = removeIndent(notationProperty?.value);
76
+ const style = this.parseStyleProps(astRule.props.filter(ast.isStyleProperty));
77
+ const notation = removeIndent(astRule.props.find(ast.isNotationProperty)?.value);
94
78
  const targets = this.parseFqnExpressions(astRule.targets);
95
79
  return {
96
80
  targets,
97
- ...notation && { notation },
98
- style: {
99
- ...toElementStyle(styleProps, this.isValid)
100
- }
81
+ style,
82
+ ...notation && { notation }
101
83
  };
102
84
  }
103
85
  };
@@ -1,19 +1,31 @@
1
1
  import type * as c4 from '@likec4/core';
2
2
  import { ast } from '../../ast';
3
- import type { Base } from './Base';
3
+ import { type Base } from './Base';
4
4
  export type WithExpressionV2 = ReturnType<typeof ExpressionV2Parser>;
5
5
  export declare function ExpressionV2Parser<TBase extends Base>(B: TBase): {
6
6
  new (...args: any[]): {
7
7
  parseFqnRef(astNode: ast.FqnRef): c4.FqnRef;
8
+ parseExpressionV2(astNode: ast.ExpressionV2): c4.ExpressionV2;
9
+ parseFqnExprOrWith(astNode: ast.FqnExprOrWith): c4.FqnExpr.Any;
10
+ parseFqnExprWith(astNode: ast.FqnExprWith): c4.FqnExpr.Custom;
11
+ parseFqnExprOrWhere(astNode: ast.FqnExprOrWhere): c4.FqnExpr.OrWhere;
12
+ parseFqnExprWhere(astNode: ast.FqnExprWhere): c4.FqnExpr.Where;
8
13
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
9
14
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
10
- parseElementWhereExpr(astNode: ast.ElementPredicateWhereV2): c4.RelationExpr;
11
15
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
12
- parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
16
+ parseRelationExprOrWith(astNode: ast.RelationExprOrWith): c4.RelationExpr.Any;
17
+ parseRelationExprWith(astNode: ast.RelationExprWith): c4.RelationExpr.Custom;
18
+ parseRelationExprOrWhere(astNode: ast.RelationExprOrWhere): c4.RelationExpr.OrWhere;
19
+ parseRelationExprWhere(astNode: ast.RelationExprWhere): c4.RelationExpr.Where;
13
20
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
14
21
  isValid: import("../../validation").IsValidFn;
15
22
  readonly services: import("../..").LikeC4Services;
16
23
  readonly doc: import("../../ast").ParsedLikeC4LangiumDocument;
24
+ readonly project: {
25
+ id: c4.ProjectId;
26
+ folder: c4;
27
+ config: Readonly<import("../../config").ProjectConfig>;
28
+ };
17
29
  resolveFqn(node: ast.FqnReferenceable): c4.Fqn;
18
30
  getAstNodePath(node: c4): any;
19
31
  getMetadata(metadataAstNode: ast.MetadataProperty | undefined): {
@@ -27,5 +39,8 @@ export declare function ExpressionV2Parser<TBase extends Base>(B: TBase): {
27
39
  }>(withTags?: E): c4.NonEmptyArray<c4.Tag> | null;
28
40
  convertLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
29
41
  parseLinks(source?: ast.LinkProperty["$container"]): c4.Link[] | undefined;
42
+ parseIconProperty(prop: ast.IconProperty | undefined): c4.IconUrl | undefined;
43
+ parseElementStyle(elementProps: Array<ast.ElementProperty> | ast.ElementStyleProperty | undefined): import("../../ast").ParsedElementStyle;
44
+ parseStyleProps(styleProps: Array<ast.StyleProperty> | undefined): import("../../ast").ParsedElementStyle;
30
45
  };
31
46
  } & TBase;