@likec4/language-server 0.46.0 → 0.47.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 (41) hide show
  1. package/contrib/likec4.monarch.ts +5 -8
  2. package/contrib/likec4.tmLanguage.json +1 -1
  3. package/dist/ast.d.ts +8 -3
  4. package/dist/ast.js +12 -8
  5. package/dist/generated/ast.d.ts +152 -110
  6. package/dist/generated/ast.js +149 -94
  7. package/dist/generated/grammar.js +1 -1
  8. package/dist/lsp/DocumentSymbolProvider.d.ts +7 -2
  9. package/dist/lsp/DocumentSymbolProvider.js +63 -56
  10. package/dist/lsp/HoverProvider.js +2 -8
  11. package/dist/lsp/SemanticTokenProvider.js +15 -25
  12. package/dist/model/fqn-index.d.ts +2 -7
  13. package/dist/model/fqn-index.js +14 -26
  14. package/dist/model/model-builder.js +5 -3
  15. package/dist/model/model-parser.d.ts +3 -2
  16. package/dist/model/model-parser.js +111 -51
  17. package/dist/module.js +3 -2
  18. package/dist/references/scope-computation.js +35 -15
  19. package/dist/references/scope-provider.d.ts +1 -2
  20. package/dist/references/scope-provider.js +17 -25
  21. package/dist/shared/NodeKindProvider.d.ts +4 -2
  22. package/dist/shared/NodeKindProvider.js +40 -13
  23. package/dist/shared/WorkspaceSymbolProvider.d.ts +4 -0
  24. package/dist/shared/WorkspaceSymbolProvider.js +3 -0
  25. package/dist/shared/index.d.ts +2 -0
  26. package/dist/shared/index.js +2 -0
  27. package/dist/test/testServices.d.ts +5 -0
  28. package/dist/test/testServices.js +25 -13
  29. package/dist/validation/index.js +22 -14
  30. package/dist/validation/specification.js +2 -1
  31. package/dist/validation/view-predicates/custom-element-expr.d.ts +5 -0
  32. package/dist/validation/view-predicates/custom-element-expr.js +16 -0
  33. package/dist/validation/view-predicates/incoming.d.ts +1 -1
  34. package/dist/validation/view-predicates/incoming.js +1 -1
  35. package/dist/validation/view-predicates/index.d.ts +1 -0
  36. package/dist/validation/view-predicates/index.js +1 -0
  37. package/dist/validation/view-predicates/outgoing.d.ts +1 -1
  38. package/dist/validation/view-predicates/outgoing.js +1 -1
  39. package/dist/validation/view.js +1 -1
  40. package/dist/view-utils/assignNavigateTo.js +3 -0
  41. package/package.json +6 -5
@@ -7,24 +7,22 @@ export const LikeC4Terminals = {
7
7
  URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
8
8
  RArrow: /->/,
9
9
  DotWildcard: /\b\.\*/,
10
+ TagHash: /\#\b/,
10
11
  Dot: /\b\./,
11
- NotEqual: /!=/,
12
+ NotEqual: /\!\={1,2}/,
12
13
  Eq: /\={1,2}/,
13
- OpenBlock: /\{/,
14
- CloseBlock: /\}/,
15
14
  Colon: /:/,
16
15
  SemiColon: /;/,
17
16
  Comma: /,/,
18
17
  String: /"[^"]*"|'[^']*'/,
19
- TagID: /((#)([^\W\d_])(((([^\W\d_])|([0-9]))|(_))|(-))*)/,
20
- ID: /((([^\W\d_])|(_))(((([^\W\d_])|([0-9]))|(_))|(-))*)/
18
+ ID: /((([^\W\d_])|((_)+(([^\W\d_])|([0-9]))))(((([^\W\d_])|([0-9]))|(_))|(-))*)/
21
19
  };
22
20
  export function isArrowType(item) {
23
21
  return item === "none" || item === "normal" || item === "onormal" || item === "diamond" || item === "odiamond" || item === "crow" || item === "open" || item === "vee";
24
22
  }
25
- export const ElementExpression = "ElementExpression";
26
- export function isElementExpression(item) {
27
- return reflection.isInstance(item, ElementExpression);
23
+ export const ElementExpr = "ElementExpr";
24
+ export function isElementExpr(item) {
25
+ return reflection.isInstance(item, ElementExpr);
28
26
  }
29
27
  export const ElementProperty = "ElementProperty";
30
28
  export function isElementProperty(item) {
@@ -33,36 +31,51 @@ export function isElementProperty(item) {
33
31
  export function isElementShape(item) {
34
32
  return item === "rectangle" || item === "person" || item === "browser" || item === "mobile" || item === "cylinder" || item === "storage" || item === "queue";
35
33
  }
36
- export const Expression = "Expression";
37
- export function isExpression(item) {
38
- return reflection.isInstance(item, Expression);
39
- }
40
34
  export function isLineOptions(item) {
41
35
  return item === "solid" || item === "dashed" || item === "dotted";
42
36
  }
43
37
  export function isName(item) {
44
- return isElementShape(item) || isThemeColor(item) || isLineOptions(item) || isArrowType(item) || item === "element" || item === "model" || typeof item === "string" && /((([^\W\d_])|(_))(((([^\W\d_])|([0-9]))|(_))|(-))*)/.test(item);
38
+ return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" && /((([^\W\d_])|((_)+(([^\W\d_])|([0-9]))))(((([^\W\d_])|([0-9]))|(_))|(-))*)/.test(item);
45
39
  }
46
40
  export const Relation = "Relation";
47
41
  export function isRelation(item) {
48
42
  return reflection.isInstance(item, Relation);
49
43
  }
44
+ export const RelationshipStyleProperty = "RelationshipStyleProperty";
45
+ export function isRelationshipStyleProperty(item) {
46
+ return reflection.isInstance(item, RelationshipStyleProperty);
47
+ }
48
+ export const StyleProperty = "StyleProperty";
49
+ export function isStyleProperty(item) {
50
+ return reflection.isInstance(item, StyleProperty);
51
+ }
52
+ export function isTagID(item) {
53
+ return typeof item === "string";
54
+ }
50
55
  export function isThemeColor(item) {
51
56
  return item === "primary" || item === "secondary" || item === "muted" || item === "slate" || item === "blue" || item === "indigo" || item === "sky" || item === "red" || item === "gray" || item === "green" || item === "amber";
52
57
  }
53
58
  export function isUri(item) {
54
59
  return typeof item === "string" && (/\w+:\/\/\S+/.test(item) || /\.{0,2}\/[^\/]\S+/.test(item));
55
60
  }
56
- export const View = "View";
57
- export function isView(item) {
58
- return reflection.isInstance(item, View);
61
+ export function isViewLayoutDirection(item) {
62
+ return item === "TopBottom" || item === "LeftRight" || item === "BottomTop" || item === "RightLeft";
63
+ }
64
+ export const ViewProperty = "ViewProperty";
65
+ export function isViewProperty(item) {
66
+ return reflection.isInstance(item, ViewProperty);
59
67
  }
60
68
  export const ViewRule = "ViewRule";
61
69
  export function isViewRule(item) {
62
70
  return reflection.isInstance(item, ViewRule);
63
71
  }
64
- export function isViewRuleLayoutDirection(item) {
65
- return item === "TopBottom" || item === "LeftRight" || item === "BottomTop" || item === "RightLeft";
72
+ export const ViewRulePredicate = "ViewRulePredicate";
73
+ export function isViewRulePredicate(item) {
74
+ return reflection.isInstance(item, ViewRulePredicate);
75
+ }
76
+ export const ViewRulePredicateExpr = "ViewRulePredicateExpr";
77
+ export function isViewRulePredicateExpr(item) {
78
+ return reflection.isInstance(item, ViewRulePredicateExpr);
66
79
  }
67
80
  export const ArrowProperty = "ArrowProperty";
68
81
  export function isArrowProperty(item) {
@@ -72,6 +85,18 @@ export const ColorProperty = "ColorProperty";
72
85
  export function isColorProperty(item) {
73
86
  return reflection.isInstance(item, ColorProperty);
74
87
  }
88
+ export const CustomElementExpr = "CustomElementExpr";
89
+ export function isCustomElementExpr(item) {
90
+ return reflection.isInstance(item, CustomElementExpr);
91
+ }
92
+ export const CustomElementExprBody = "CustomElementExprBody";
93
+ export function isCustomElementExprBody(item) {
94
+ return reflection.isInstance(item, CustomElementExprBody);
95
+ }
96
+ export const DescedantsExpr = "DescedantsExpr";
97
+ export function isDescedantsExpr(item) {
98
+ return reflection.isInstance(item, DescedantsExpr);
99
+ }
75
100
  export const Element = "Element";
76
101
  export function isElement(item) {
77
102
  return reflection.isInstance(item, Element);
@@ -84,25 +109,21 @@ export const ElementKind = "ElementKind";
84
109
  export function isElementKind(item) {
85
110
  return reflection.isInstance(item, ElementKind);
86
111
  }
87
- export const ElementKindExpression = "ElementKindExpression";
88
- export function isElementKindExpression(item) {
89
- return reflection.isInstance(item, ElementKindExpression);
112
+ export const ElementKindExpr = "ElementKindExpr";
113
+ export function isElementKindExpr(item) {
114
+ return reflection.isInstance(item, ElementKindExpr);
90
115
  }
91
116
  export const ElementRef = "ElementRef";
92
117
  export function isElementRef(item) {
93
118
  return reflection.isInstance(item, ElementRef);
94
119
  }
95
- export const ElementRefExpression = "ElementRefExpression";
96
- export function isElementRefExpression(item) {
97
- return reflection.isInstance(item, ElementRefExpression);
98
- }
99
120
  export const ElementStringProperty = "ElementStringProperty";
100
121
  export function isElementStringProperty(item) {
101
122
  return reflection.isInstance(item, ElementStringProperty);
102
123
  }
103
- export const ElementTagExpression = "ElementTagExpression";
104
- export function isElementTagExpression(item) {
105
- return reflection.isInstance(item, ElementTagExpression);
124
+ export const ElementTagExpr = "ElementTagExpr";
125
+ export function isElementTagExpr(item) {
126
+ return reflection.isInstance(item, ElementTagExpr);
106
127
  }
107
128
  export const ElementView = "ElementView";
108
129
  export function isElementView(item) {
@@ -116,6 +137,10 @@ export const ElementViewRef = "ElementViewRef";
116
137
  export function isElementViewRef(item) {
117
138
  return reflection.isInstance(item, ElementViewRef);
118
139
  }
140
+ export const ExcludePredicate = "ExcludePredicate";
141
+ export function isExcludePredicate(item) {
142
+ return reflection.isInstance(item, ExcludePredicate);
143
+ }
119
144
  export const ExplicitRelation = "ExplicitRelation";
120
145
  export function isExplicitRelation(item) {
121
146
  return reflection.isInstance(item, ExplicitRelation);
@@ -140,13 +165,17 @@ export const ImplicitRelation = "ImplicitRelation";
140
165
  export function isImplicitRelation(item) {
141
166
  return reflection.isInstance(item, ImplicitRelation);
142
167
  }
143
- export const IncomingExpression = "IncomingExpression";
144
- export function isIncomingExpression(item) {
145
- return reflection.isInstance(item, IncomingExpression);
168
+ export const IncludePredicate = "IncludePredicate";
169
+ export function isIncludePredicate(item) {
170
+ return reflection.isInstance(item, IncludePredicate);
146
171
  }
147
- export const InOutExpression = "InOutExpression";
148
- export function isInOutExpression(item) {
149
- return reflection.isInstance(item, InOutExpression);
172
+ export const IncomingExpr = "IncomingExpr";
173
+ export function isIncomingExpr(item) {
174
+ return reflection.isInstance(item, IncomingExpr);
175
+ }
176
+ export const InOutExpr = "InOutExpr";
177
+ export function isInOutExpr(item) {
178
+ return reflection.isInstance(item, InOutExpr);
150
179
  }
151
180
  export const LikeC4Grammar = "LikeC4Grammar";
152
181
  export function isLikeC4Grammar(item) {
@@ -168,13 +197,17 @@ export const ModelViews = "ModelViews";
168
197
  export function isModelViews(item) {
169
198
  return reflection.isInstance(item, ModelViews);
170
199
  }
171
- export const OutgoingExpression = "OutgoingExpression";
172
- export function isOutgoingExpression(item) {
173
- return reflection.isInstance(item, OutgoingExpression);
200
+ export const NavigateToProperty = "NavigateToProperty";
201
+ export function isNavigateToProperty(item) {
202
+ return reflection.isInstance(item, NavigateToProperty);
203
+ }
204
+ export const OutgoingExpr = "OutgoingExpr";
205
+ export function isOutgoingExpr(item) {
206
+ return reflection.isInstance(item, OutgoingExpr);
174
207
  }
175
- export const RelationExpression = "RelationExpression";
176
- export function isRelationExpression(item) {
177
- return reflection.isInstance(item, RelationExpression);
208
+ export const RelationExpr = "RelationExpr";
209
+ export function isRelationExpr(item) {
210
+ return reflection.isInstance(item, RelationExpr);
178
211
  }
179
212
  export const RelationshipKind = "RelationshipKind";
180
213
  export function isRelationshipKind(item) {
@@ -216,62 +249,77 @@ export const Tags = "Tags";
216
249
  export function isTags(item) {
217
250
  return reflection.isInstance(item, Tags);
218
251
  }
219
- export const ViewProperty = "ViewProperty";
220
- export function isViewProperty(item) {
221
- return reflection.isInstance(item, ViewProperty);
222
- }
223
252
  export const ViewRuleAutoLayout = "ViewRuleAutoLayout";
224
253
  export function isViewRuleAutoLayout(item) {
225
254
  return reflection.isInstance(item, ViewRuleAutoLayout);
226
255
  }
227
- export const ViewRuleExpression = "ViewRuleExpression";
228
- export function isViewRuleExpression(item) {
229
- return reflection.isInstance(item, ViewRuleExpression);
230
- }
231
256
  export const ViewRuleStyle = "ViewRuleStyle";
232
257
  export function isViewRuleStyle(item) {
233
258
  return reflection.isInstance(item, ViewRuleStyle);
234
259
  }
235
- export const WildcardExpression = "WildcardExpression";
236
- export function isWildcardExpression(item) {
237
- return reflection.isInstance(item, WildcardExpression);
260
+ export const ViewStringProperty = "ViewStringProperty";
261
+ export function isViewStringProperty(item) {
262
+ return reflection.isInstance(item, ViewStringProperty);
263
+ }
264
+ export const WildcardExpr = "WildcardExpr";
265
+ export function isWildcardExpr(item) {
266
+ return reflection.isInstance(item, WildcardExpr);
238
267
  }
239
268
  export class LikeC4AstReflection extends AbstractAstReflection {
240
269
  getAllTypes() {
241
- return ["ArrowProperty", "ColorProperty", "Element", "ElementBody", "ElementExpression", "ElementKind", "ElementKindExpression", "ElementProperty", "ElementRef", "ElementRefExpression", "ElementStringProperty", "ElementTagExpression", "ElementView", "ElementViewBody", "ElementViewRef", "ExplicitRelation", "Expression", "ExtendElement", "ExtendElementBody", "FqnElementRef", "IconProperty", "ImplicitRelation", "InOutExpression", "IncomingExpression", "LikeC4Grammar", "LineProperty", "LinkProperty", "Model", "ModelViews", "OutgoingExpression", "Relation", "RelationExpression", "RelationStringProperty", "RelationshipKind", "ShapeProperty", "SpecificationElementKind", "SpecificationRelationshipKind", "SpecificationRule", "SpecificationTag", "StyleProperties", "Tag", "Tags", "View", "ViewProperty", "ViewRule", "ViewRuleAutoLayout", "ViewRuleExpression", "ViewRuleStyle", "WildcardExpression"];
270
+ return ["ArrowProperty", "ColorProperty", "CustomElementExpr", "CustomElementExprBody", "DescedantsExpr", "Element", "ElementBody", "ElementExpr", "ElementKind", "ElementKindExpr", "ElementProperty", "ElementRef", "ElementStringProperty", "ElementTagExpr", "ElementView", "ElementViewBody", "ElementViewRef", "ExcludePredicate", "ExplicitRelation", "ExtendElement", "ExtendElementBody", "FqnElementRef", "IconProperty", "ImplicitRelation", "InOutExpr", "IncludePredicate", "IncomingExpr", "LikeC4Grammar", "LineProperty", "LinkProperty", "Model", "ModelViews", "NavigateToProperty", "OutgoingExpr", "Relation", "RelationExpr", "RelationStringProperty", "RelationshipKind", "RelationshipStyleProperty", "ShapeProperty", "SpecificationElementKind", "SpecificationRelationshipKind", "SpecificationRule", "SpecificationTag", "StyleProperties", "StyleProperty", "Tag", "Tags", "ViewProperty", "ViewRule", "ViewRuleAutoLayout", "ViewRulePredicate", "ViewRulePredicateExpr", "ViewRuleStyle", "ViewStringProperty", "WildcardExpr"];
242
271
  }
243
272
  computeIsSubtype(subtype, supertype) {
244
273
  switch (subtype) {
245
- case ElementExpression:
246
- case IncomingExpression:
247
- case InOutExpression:
248
- case OutgoingExpression:
249
- case RelationExpression: {
250
- return this.isSubtype(Expression, supertype);
251
- }
252
- case ElementKindExpression:
253
- case ElementRefExpression:
254
- case ElementTagExpression:
255
- case WildcardExpression: {
256
- return this.isSubtype(ElementExpression, supertype);
274
+ case ArrowProperty:
275
+ case LineProperty: {
276
+ return this.isSubtype(RelationshipStyleProperty, supertype);
277
+ }
278
+ case ColorProperty: {
279
+ return this.isSubtype(RelationshipStyleProperty, supertype) || this.isSubtype(StyleProperty, supertype);
280
+ }
281
+ case CustomElementExpr:
282
+ case ElementExpr:
283
+ case IncomingExpr:
284
+ case InOutExpr:
285
+ case OutgoingExpr:
286
+ case RelationExpr: {
287
+ return this.isSubtype(ViewRulePredicateExpr, supertype);
288
+ }
289
+ case DescedantsExpr:
290
+ case ElementKindExpr:
291
+ case ElementRef:
292
+ case ElementTagExpr:
293
+ case WildcardExpr: {
294
+ return this.isSubtype(ElementExpr, supertype);
257
295
  }
258
296
  case ElementStringProperty:
259
- case LinkProperty:
260
297
  case StyleProperties: {
261
298
  return this.isSubtype(ElementProperty, supertype);
262
299
  }
263
- case ElementView: {
264
- return this.isSubtype(View, supertype);
300
+ case ExcludePredicate:
301
+ case IncludePredicate: {
302
+ return this.isSubtype(ViewRulePredicate, supertype);
265
303
  }
266
304
  case ExplicitRelation:
267
305
  case ImplicitRelation: {
268
306
  return this.isSubtype(Relation, supertype);
269
307
  }
308
+ case IconProperty:
309
+ case ShapeProperty: {
310
+ return this.isSubtype(StyleProperty, supertype);
311
+ }
312
+ case LinkProperty: {
313
+ return this.isSubtype(ElementProperty, supertype) || this.isSubtype(ViewProperty, supertype);
314
+ }
270
315
  case ViewRuleAutoLayout:
271
- case ViewRuleExpression:
316
+ case ViewRulePredicate:
272
317
  case ViewRuleStyle: {
273
318
  return this.isSubtype(ViewRule, supertype);
274
319
  }
320
+ case ViewStringProperty: {
321
+ return this.isSubtype(ViewProperty, supertype);
322
+ }
275
323
  default: {
276
324
  return false;
277
325
  }
@@ -281,14 +329,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
281
329
  const referenceId = `${refInfo.container.$type}:${refInfo.property}`;
282
330
  switch (referenceId) {
283
331
  case "Element:kind":
284
- case "ElementKindExpression:kind": {
332
+ case "ElementKindExpr:kind": {
285
333
  return ElementKind;
286
334
  }
287
335
  case "ElementRef:el":
288
336
  case "FqnElementRef:el": {
289
337
  return Element;
290
338
  }
291
- case "ElementTagExpression:tag":
339
+ case "ElementTagExpr:tag":
292
340
  case "Tags:value": {
293
341
  return Tag;
294
342
  }
@@ -306,6 +354,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
306
354
  }
307
355
  getTypeMetaData(type) {
308
356
  switch (type) {
357
+ case "CustomElementExprBody": {
358
+ return {
359
+ name: "CustomElementExprBody",
360
+ mandatory: [
361
+ { name: "props", type: "array" }
362
+ ]
363
+ };
364
+ }
309
365
  case "Element": {
310
366
  return {
311
367
  name: "Element",
@@ -323,25 +379,17 @@ export class LikeC4AstReflection extends AbstractAstReflection {
323
379
  ]
324
380
  };
325
381
  }
326
- case "ElementKindExpression": {
382
+ case "ElementKindExpr": {
327
383
  return {
328
- name: "ElementKindExpression",
384
+ name: "ElementKindExpr",
329
385
  mandatory: [
330
386
  { name: "isEqual", type: "boolean" }
331
387
  ]
332
388
  };
333
389
  }
334
- case "ElementRefExpression": {
335
- return {
336
- name: "ElementRefExpression",
337
- mandatory: [
338
- { name: "isDescedants", type: "boolean" }
339
- ]
340
- };
341
- }
342
- case "ElementTagExpression": {
390
+ case "ElementTagExpr": {
343
391
  return {
344
- name: "ElementTagExpression",
392
+ name: "ElementTagExpr",
345
393
  mandatory: [
346
394
  { name: "isEqual", type: "boolean" }
347
395
  ]
@@ -356,6 +404,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
356
404
  ]
357
405
  };
358
406
  }
407
+ case "ExcludePredicate": {
408
+ return {
409
+ name: "ExcludePredicate",
410
+ mandatory: [
411
+ { name: "expressions", type: "array" }
412
+ ]
413
+ };
414
+ }
359
415
  case "ExplicitRelation": {
360
416
  return {
361
417
  name: "ExplicitRelation",
@@ -380,6 +436,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
380
436
  ]
381
437
  };
382
438
  }
439
+ case "IncludePredicate": {
440
+ return {
441
+ name: "IncludePredicate",
442
+ mandatory: [
443
+ { name: "expressions", type: "array" }
444
+ ]
445
+ };
446
+ }
383
447
  case "LikeC4Grammar": {
384
448
  return {
385
449
  name: "LikeC4Grammar",
@@ -440,27 +504,18 @@ export class LikeC4AstReflection extends AbstractAstReflection {
440
504
  ]
441
505
  };
442
506
  }
443
- case "ViewRuleExpression": {
444
- return {
445
- name: "ViewRuleExpression",
446
- mandatory: [
447
- { name: "expressions", type: "array" },
448
- { name: "isInclude", type: "boolean" }
449
- ]
450
- };
451
- }
452
507
  case "ViewRuleStyle": {
453
508
  return {
454
509
  name: "ViewRuleStyle",
455
510
  mandatory: [
456
- { name: "props", type: "array" },
511
+ { name: "styleprops", type: "array" },
457
512
  { name: "targets", type: "array" }
458
513
  ]
459
514
  };
460
515
  }
461
- case "WildcardExpression": {
516
+ case "WildcardExpr": {
462
517
  return {
463
- name: "WildcardExpression",
518
+ name: "WildcardExpr",
464
519
  mandatory: [
465
520
  { name: "isWildcard", type: "boolean" }
466
521
  ]