@likec4/language-server 1.9.0 → 1.10.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 (52) hide show
  1. package/contrib/likec4.tmLanguage.json +1 -1
  2. package/dist/browser.cjs +1 -1
  3. package/dist/browser.d.cts +3 -4
  4. package/dist/browser.d.mts +3 -4
  5. package/dist/browser.d.ts +3 -4
  6. package/dist/browser.mjs +1 -1
  7. package/dist/index.cjs +1 -1
  8. package/dist/index.d.cts +2 -2
  9. package/dist/index.d.mts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.mjs +1 -1
  12. package/dist/model-graph/index.cjs +1 -1
  13. package/dist/model-graph/index.mjs +1 -1
  14. package/dist/node.cjs +1 -1
  15. package/dist/node.d.cts +3 -4
  16. package/dist/node.d.mts +3 -4
  17. package/dist/node.d.ts +3 -4
  18. package/dist/node.mjs +1 -1
  19. package/dist/shared/{language-server.Q-wtPShM.mjs → language-server.BFBeyvV8.mjs} +486 -108
  20. package/dist/shared/{language-server.86lmJ8ZN.d.cts → language-server.BGy3FJPJ.d.cts} +43 -14
  21. package/dist/shared/{language-server.B1TZgyoH.cjs → language-server.Bfc-5M8A.cjs} +482 -104
  22. package/dist/shared/{language-server.CCB4ESN5.mjs → language-server.CbqwHp7Q.mjs} +184 -120
  23. package/dist/shared/{language-server.RjhrBZS0.d.ts → language-server.CnVuAxDh.d.ts} +43 -14
  24. package/dist/shared/{language-server.CFTY6j4e.d.mts → language-server.DEK39RmI.d.mts} +43 -14
  25. package/dist/shared/{language-server.D0bOlrCi.cjs → language-server.DJhoJBWh.cjs} +180 -116
  26. package/package.json +13 -11
  27. package/src/ast.ts +8 -6
  28. package/src/formatting/LikeC4Formatter.ts +390 -0
  29. package/src/formatting/utils.ts +26 -0
  30. package/src/generated/ast.ts +203 -11
  31. package/src/generated/grammar.ts +2 -2
  32. package/src/generated/module.ts +1 -1
  33. package/src/like-c4.langium +34 -7
  34. package/src/lsp/CompletionProvider.ts +1 -1
  35. package/src/lsp/DocumentLinkProvider.ts +27 -15
  36. package/src/lsp/SemanticTokenProvider.ts +1 -1
  37. package/src/lsp/index.ts +1 -1
  38. package/src/model/fqn-index.ts +0 -1
  39. package/src/model/model-builder.ts +43 -32
  40. package/src/model/model-parser.ts +43 -21
  41. package/src/model-graph/compute-view/compute.ts +111 -80
  42. package/src/model-graph/compute-view/predicates.ts +3 -5
  43. package/src/model-graph/dynamic-view/compute.ts +96 -60
  44. package/src/model-graph/utils/buildElementNotations.ts +1 -1
  45. package/src/model-graph/utils/uniqueTags.test.ts +42 -0
  46. package/src/model-graph/utils/uniqueTags.ts +19 -0
  47. package/src/module.ts +6 -9
  48. package/src/test/testServices.ts +27 -7
  49. package/src/validation/index.ts +2 -1
  50. package/src/validation/property-checks.ts +13 -1
  51. package/src/validation/specification.ts +3 -3
  52. package/src/view-utils/resolve-relative-paths.ts +14 -17
@@ -1,5 +1,5 @@
1
1
  /******************************************************************************
2
- * This file was generated by langium-cli 3.1.1.
2
+ * This file was generated by langium-cli 3.2.0.
3
3
  * DO NOT EDIT MANUALLY!
4
4
  ******************************************************************************/
5
5
 
@@ -10,7 +10,8 @@ import { AbstractAstReflection } from 'langium';
10
10
  export const LikeC4Terminals = {
11
11
  BLOCK_COMMENT: /\/\*[\s\S]*?\*\//,
12
12
  LINE_COMMENT: /\/\/[^\n\r]*/,
13
- WS: /\s+/,
13
+ WS: /[\t ]+/,
14
+ NL: /[\r\n]+/,
14
15
  LIB_ICON: /(aws|gcp|tech):[-\w]*/,
15
16
  URI_WITH_SCHEMA: /\w+:\/\/\S+/,
16
17
  URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
@@ -27,6 +28,104 @@ export const LikeC4Terminals = {
27
28
  Hex: /[a-zA-Z0-9]+/,
28
29
  };
29
30
 
31
+ export type LikeC4TerminalNames = keyof typeof LikeC4Terminals;
32
+
33
+ export type LikeC4KeywordNames =
34
+ | "("
35
+ | ")"
36
+ | "*"
37
+ | ","
38
+ | "->"
39
+ | "-["
40
+ | ":"
41
+ | ";"
42
+ | "<-"
43
+ | "<->"
44
+ | "BottomTop"
45
+ | "LeftRight"
46
+ | "RightLeft"
47
+ | "TopBottom"
48
+ | "]->"
49
+ | "amber"
50
+ | "and"
51
+ | "autoLayout"
52
+ | "blue"
53
+ | "border"
54
+ | "browser"
55
+ | "color"
56
+ | "crow"
57
+ | "cylinder"
58
+ | "dashed"
59
+ | "description"
60
+ | "diamond"
61
+ | "dot"
62
+ | "dotted"
63
+ | "dynamic"
64
+ | "element"
65
+ | "element.kind"
66
+ | "element.tag"
67
+ | "exclude"
68
+ | "extend"
69
+ | "extends"
70
+ | "gray"
71
+ | "green"
72
+ | "head"
73
+ | "icon"
74
+ | "icons"
75
+ | "include"
76
+ | "indigo"
77
+ | "is"
78
+ | "kind"
79
+ | "likec4lib"
80
+ | "line"
81
+ | "link"
82
+ | "metadata"
83
+ | "mobile"
84
+ | "model"
85
+ | "muted"
86
+ | "navigateTo"
87
+ | "none"
88
+ | "normal"
89
+ | "not"
90
+ | "notation"
91
+ | "notes"
92
+ | "odiamond"
93
+ | "odot"
94
+ | "of"
95
+ | "onormal"
96
+ | "opacity"
97
+ | "open"
98
+ | "or"
99
+ | "par"
100
+ | "parallel"
101
+ | "person"
102
+ | "primary"
103
+ | "queue"
104
+ | "rectangle"
105
+ | "red"
106
+ | "relationship"
107
+ | "secondary"
108
+ | "shape"
109
+ | "sky"
110
+ | "slate"
111
+ | "solid"
112
+ | "specification"
113
+ | "storage"
114
+ | "style"
115
+ | "tag"
116
+ | "tail"
117
+ | "technology"
118
+ | "title"
119
+ | "vee"
120
+ | "view"
121
+ | "views"
122
+ | "where"
123
+ | "with"
124
+ | "{"
125
+ | "}";
126
+
127
+ export type LikeC4TokenNames = LikeC4TerminalNames | LikeC4KeywordNames;
128
+
30
129
  export type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | 'odot' | 'onormal' | 'open' | 'vee';
31
130
 
32
131
  export function isArrowType(item: unknown): item is ArrowType {
@@ -169,7 +268,7 @@ export function isRelationPredicateOrWhere(item: unknown): item is RelationPredi
169
268
  return reflection.isInstance(item, RelationPredicateOrWhere);
170
269
  }
171
270
 
172
- export type RelationProperty = LinkProperty | MetadataProperty | RelationStringProperty | RelationStyleProperty;
271
+ export type RelationProperty = LinkProperty | MetadataProperty | RelationNavigateToProperty | RelationStringProperty | RelationStyleProperty;
173
272
 
174
273
  export const RelationProperty = 'RelationProperty';
175
274
 
@@ -185,7 +284,7 @@ export function isRelationshipStyleProperty(item: unknown): item is Relationship
185
284
  return reflection.isInstance(item, RelationshipStyleProperty);
186
285
  }
187
286
 
188
- export type StringProperty = ElementStringProperty | MetadataAttribute | NotationProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
287
+ export type StringProperty = ElementStringProperty | MetadataAttribute | NotationProperty | NotesProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
189
288
 
190
289
  export const StringProperty = 'StringProperty';
191
290
 
@@ -372,7 +471,7 @@ export function isCustomElementProperties(item: unknown): item is CustomElementP
372
471
  export interface CustomRelationProperties extends AstNode {
373
472
  readonly $container: DynamicViewStep | RelationPredicateWith;
374
473
  readonly $type: 'CustomRelationProperties';
375
- props: Array<NotationProperty | RelationStringProperty | RelationshipStyleProperty>;
474
+ props: Array<NotationProperty | NotesProperty | RelationNavigateToProperty | RelationStringProperty | RelationshipStyleProperty>;
376
475
  }
377
476
 
378
477
  export const CustomRelationProperties = 'CustomRelationProperties';
@@ -412,7 +511,7 @@ export interface DynamicViewBody extends AstNode {
412
511
  readonly $type: 'DynamicViewBody';
413
512
  props: Array<ViewProperty>;
414
513
  rules: Array<DynamicViewRule>;
415
- steps: Array<DynamicViewStep>;
514
+ steps: Array<DynamicViewParallelSteps | DynamicViewStep>;
416
515
  tags?: Tags;
417
516
  }
418
517
 
@@ -434,6 +533,18 @@ export function isDynamicViewIncludePredicate(item: unknown): item is DynamicVie
434
533
  return reflection.isInstance(item, DynamicViewIncludePredicate);
435
534
  }
436
535
 
536
+ export interface DynamicViewParallelSteps extends AstNode {
537
+ readonly $container: DynamicViewBody;
538
+ readonly $type: 'DynamicViewParallelSteps';
539
+ steps: Array<DynamicViewStep>;
540
+ }
541
+
542
+ export const DynamicViewParallelSteps = 'DynamicViewParallelSteps';
543
+
544
+ export function isDynamicViewParallelSteps(item: unknown): item is DynamicViewParallelSteps {
545
+ return reflection.isInstance(item, DynamicViewParallelSteps);
546
+ }
547
+
437
548
  export interface DynamicViewPredicateIterator extends AstNode {
438
549
  readonly $container: DynamicViewIncludePredicate | DynamicViewPredicateIterator;
439
550
  readonly $type: 'DynamicViewPredicateIterator';
@@ -447,8 +558,20 @@ export function isDynamicViewPredicateIterator(item: unknown): item is DynamicVi
447
558
  return reflection.isInstance(item, DynamicViewPredicateIterator);
448
559
  }
449
560
 
561
+ export interface DynamicViewRef extends AstNode {
562
+ readonly $container: RelationNavigateToProperty;
563
+ readonly $type: 'DynamicViewRef';
564
+ view: Reference<DynamicView>;
565
+ }
566
+
567
+ export const DynamicViewRef = 'DynamicViewRef';
568
+
569
+ export function isDynamicViewRef(item: unknown): item is DynamicViewRef {
570
+ return reflection.isInstance(item, DynamicViewRef);
571
+ }
572
+
450
573
  export interface DynamicViewStep extends AstNode {
451
- readonly $container: DynamicViewBody;
574
+ readonly $container: DynamicViewBody | DynamicViewParallelSteps;
452
575
  readonly $type: 'DynamicViewStep';
453
576
  custom?: CustomRelationProperties;
454
577
  isBackward: boolean;
@@ -916,6 +1039,19 @@ export function isNotationProperty(item: unknown): item is NotationProperty {
916
1039
  return reflection.isInstance(item, NotationProperty);
917
1040
  }
918
1041
 
1042
+ export interface NotesProperty extends AstNode {
1043
+ readonly $container: CustomRelationProperties;
1044
+ readonly $type: 'NotesProperty';
1045
+ key: 'notes';
1046
+ value: string;
1047
+ }
1048
+
1049
+ export const NotesProperty = 'NotesProperty';
1050
+
1051
+ export function isNotesProperty(item: unknown): item is NotesProperty {
1052
+ return reflection.isInstance(item, NotesProperty);
1053
+ }
1054
+
919
1055
  export interface OpacityProperty extends AstNode {
920
1056
  readonly $container: CustomElementProperties | ElementStyleProperty | ViewRuleStyle;
921
1057
  readonly $type: 'OpacityProperty';
@@ -987,6 +1123,19 @@ export function isRelationBody(item: unknown): item is RelationBody {
987
1123
  return reflection.isInstance(item, RelationBody);
988
1124
  }
989
1125
 
1126
+ export interface RelationNavigateToProperty extends AstNode {
1127
+ readonly $container: CustomRelationProperties | RelationBody;
1128
+ readonly $type: 'RelationNavigateToProperty';
1129
+ key: 'navigateTo';
1130
+ value: DynamicViewRef;
1131
+ }
1132
+
1133
+ export const RelationNavigateToProperty = 'RelationNavigateToProperty';
1134
+
1135
+ export function isRelationNavigateToProperty(item: unknown): item is RelationNavigateToProperty {
1136
+ return reflection.isInstance(item, RelationNavigateToProperty);
1137
+ }
1138
+
990
1139
  export interface RelationPredicateWhere extends AstNode {
991
1140
  readonly $container: Predicates | RelationPredicateWith;
992
1141
  readonly $type: 'RelationPredicateWhere';
@@ -1349,7 +1498,9 @@ export type LikeC4AstType = {
1349
1498
  DynamicView: DynamicView
1350
1499
  DynamicViewBody: DynamicViewBody
1351
1500
  DynamicViewIncludePredicate: DynamicViewIncludePredicate
1501
+ DynamicViewParallelSteps: DynamicViewParallelSteps
1352
1502
  DynamicViewPredicateIterator: DynamicViewPredicateIterator
1503
+ DynamicViewRef: DynamicViewRef
1353
1504
  DynamicViewRule: DynamicViewRule
1354
1505
  DynamicViewStep: DynamicViewStep
1355
1506
  Element: Element
@@ -1393,6 +1544,7 @@ export type LikeC4AstType = {
1393
1544
  ModelViews: ModelViews
1394
1545
  NavigateToProperty: NavigateToProperty
1395
1546
  NotationProperty: NotationProperty
1547
+ NotesProperty: NotesProperty
1396
1548
  OpacityProperty: OpacityProperty
1397
1549
  OutgoingRelationExpression: OutgoingRelationExpression
1398
1550
  Predicate: Predicate
@@ -1400,6 +1552,7 @@ export type LikeC4AstType = {
1400
1552
  Relation: Relation
1401
1553
  RelationBody: RelationBody
1402
1554
  RelationExpression: RelationExpression
1555
+ RelationNavigateToProperty: RelationNavigateToProperty
1403
1556
  RelationPredicate: RelationPredicate
1404
1557
  RelationPredicateOrWhere: RelationPredicateOrWhere
1405
1558
  RelationPredicateWhere: RelationPredicateWhere
@@ -1448,7 +1601,7 @@ export type LikeC4AstType = {
1448
1601
  export class LikeC4AstReflection extends AbstractAstReflection {
1449
1602
 
1450
1603
  getAllTypes(): string[] {
1451
- return [ArrowProperty, BorderProperty, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DirectedRelationExpression, DynamicView, DynamicViewBody, DynamicViewIncludePredicate, DynamicViewPredicateIterator, DynamicViewRule, DynamicViewStep, Element, ElementBody, ElementDescedantsExpression, ElementExpression, ElementExpressionsIterator, ElementKind, ElementKindExpression, ElementPredicate, ElementPredicateOrWhere, ElementPredicateWhere, ElementPredicateWith, ElementProperty, ElementRef, ElementStringProperty, ElementStyleProperty, ElementTagExpression, ElementView, ElementViewBody, ElementViewRef, ExcludePredicate, ExpandElementExpression, ExtendElement, ExtendElementBody, FqnElementRef, IconProperty, InOutRelationExpression, IncludePredicate, IncomingRelationExpression, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelViews, NavigateToProperty, NotationProperty, OpacityProperty, OutgoingRelationExpression, Predicate, Predicates, Relation, RelationBody, RelationExpression, RelationPredicate, RelationPredicateOrWhere, RelationPredicateWhere, RelationPredicateWith, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, SpecificationColor, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StringProperty, StyleProperty, Tag, Tags, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRulePredicate, ViewRuleStyle, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationTag, WhereTagEqual, WildcardExpression];
1604
+ return [ArrowProperty, BorderProperty, ColorProperty, CustomColor, CustomElementProperties, CustomRelationProperties, DirectedRelationExpression, DynamicView, DynamicViewBody, 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, ExtendElement, ExtendElementBody, FqnElementRef, IconProperty, InOutRelationExpression, IncludePredicate, IncomingRelationExpression, LibIcon, LikeC4Grammar, LikeC4Lib, LikeC4View, LineProperty, LinkProperty, MetadataAttribute, MetadataBody, MetadataProperty, Model, ModelViews, NavigateToProperty, NotationProperty, NotesProperty, OpacityProperty, OutgoingRelationExpression, Predicate, Predicates, Relation, RelationBody, RelationExpression, RelationNavigateToProperty, RelationPredicate, RelationPredicateOrWhere, RelationPredicateWhere, RelationPredicateWith, RelationProperty, RelationStringProperty, RelationStyleProperty, RelationshipKind, RelationshipStyleProperty, ShapeProperty, SpecificationColor, SpecificationElementKind, SpecificationElementStringProperty, SpecificationRelationshipKind, SpecificationRelationshipStringProperty, SpecificationRule, SpecificationTag, StringProperty, StyleProperty, Tag, Tags, ViewProperty, ViewRef, ViewRule, ViewRuleAutoLayout, ViewRulePredicate, ViewRuleStyle, ViewStringProperty, WhereBinaryExpression, WhereElement, WhereElementExpression, WhereElementKind, WhereElementNegation, WhereElementTag, WhereExpression, WhereKindEqual, WhereRelation, WhereRelationExpression, WhereRelationKind, WhereRelationNegation, WhereRelationTag, WhereTagEqual, WildcardExpression];
1452
1605
  }
1453
1606
 
1454
1607
  protected override computeIsSubtype(subtype: string, supertype: string): boolean {
@@ -1516,6 +1669,7 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1516
1669
  }
1517
1670
  case MetadataAttribute:
1518
1671
  case NotationProperty:
1672
+ case NotesProperty:
1519
1673
  case SpecificationElementStringProperty:
1520
1674
  case SpecificationRelationshipStringProperty: {
1521
1675
  return this.isSubtype(StringProperty, supertype);
@@ -1530,6 +1684,10 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1530
1684
  case RelationPredicateWhere: {
1531
1685
  return this.isSubtype(RelationPredicateOrWhere, supertype);
1532
1686
  }
1687
+ case RelationNavigateToProperty:
1688
+ case RelationStyleProperty: {
1689
+ return this.isSubtype(RelationProperty, supertype);
1690
+ }
1533
1691
  case RelationPredicateOrWhere:
1534
1692
  case RelationPredicateWith: {
1535
1693
  return this.isSubtype(RelationPredicate, supertype);
@@ -1537,9 +1695,6 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1537
1695
  case RelationStringProperty: {
1538
1696
  return this.isSubtype(RelationProperty, supertype) || this.isSubtype(StringProperty, supertype);
1539
1697
  }
1540
- case RelationStyleProperty: {
1541
- return this.isSubtype(RelationProperty, supertype);
1542
- }
1543
1698
  case ViewRuleAutoLayout:
1544
1699
  case ViewRuleStyle: {
1545
1700
  return this.isSubtype(DynamicViewRule, supertype) || this.isSubtype(ViewRule, supertype);
@@ -1589,6 +1744,9 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1589
1744
  case 'ColorProperty:customColor': {
1590
1745
  return CustomColor;
1591
1746
  }
1747
+ case 'DynamicViewRef:view': {
1748
+ return DynamicView;
1749
+ }
1592
1750
  case 'DynamicViewStep:kind':
1593
1751
  case 'OutgoingRelationExpression:kind':
1594
1752
  case 'Relation:kind':
@@ -1716,6 +1874,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1716
1874
  ]
1717
1875
  };
1718
1876
  }
1877
+ case DynamicViewParallelSteps: {
1878
+ return {
1879
+ name: DynamicViewParallelSteps,
1880
+ properties: [
1881
+ { name: 'steps', defaultValue: [] }
1882
+ ]
1883
+ };
1884
+ }
1719
1885
  case DynamicViewPredicateIterator: {
1720
1886
  return {
1721
1887
  name: DynamicViewPredicateIterator,
@@ -1725,6 +1891,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1725
1891
  ]
1726
1892
  };
1727
1893
  }
1894
+ case DynamicViewRef: {
1895
+ return {
1896
+ name: DynamicViewRef,
1897
+ properties: [
1898
+ { name: 'view' }
1899
+ ]
1900
+ };
1901
+ }
1728
1902
  case DynamicViewStep: {
1729
1903
  return {
1730
1904
  name: DynamicViewStep,
@@ -2051,6 +2225,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
2051
2225
  ]
2052
2226
  };
2053
2227
  }
2228
+ case NotesProperty: {
2229
+ return {
2230
+ name: NotesProperty,
2231
+ properties: [
2232
+ { name: 'key' },
2233
+ { name: 'value' }
2234
+ ]
2235
+ };
2236
+ }
2054
2237
  case OpacityProperty: {
2055
2238
  return {
2056
2239
  name: OpacityProperty,
@@ -2102,6 +2285,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
2102
2285
  ]
2103
2286
  };
2104
2287
  }
2288
+ case RelationNavigateToProperty: {
2289
+ return {
2290
+ name: RelationNavigateToProperty,
2291
+ properties: [
2292
+ { name: 'key' },
2293
+ { name: 'value' }
2294
+ ]
2295
+ };
2296
+ }
2105
2297
  case RelationPredicateWhere: {
2106
2298
  return {
2107
2299
  name: RelationPredicateWhere,