@likec4/language-server 1.14.0 → 1.15.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 (46) hide show
  1. package/contrib/likec4.tmLanguage.json +1 -1
  2. package/dist/browser.cjs +1 -1
  3. package/dist/browser.d.cts +2 -2
  4. package/dist/browser.d.mts +2 -2
  5. package/dist/browser.d.ts +2 -2
  6. package/dist/browser.mjs +2 -2
  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 +2 -2
  12. package/dist/likec4lib.cjs +0 -1
  13. package/dist/likec4lib.mjs +0 -1
  14. package/dist/model-graph/index.cjs +1 -1
  15. package/dist/model-graph/index.mjs +1 -1
  16. package/dist/shared/{language-server.CbDa016p.cjs → language-server.B8s2wfT_.cjs} +279 -68
  17. package/dist/shared/{language-server.DFLaUdYu.mjs → language-server.BT4WTbFI.mjs} +281 -70
  18. package/dist/shared/{language-server.DZYziEuF.mjs → language-server.BuChFlda.mjs} +231 -44
  19. package/dist/shared/{language-server.CO6aEDQm.d.mts → language-server.DfMwkd2l.d.mts} +46 -15
  20. package/dist/shared/{language-server.CITj0XN3.cjs → language-server.DfjkvknB.cjs} +230 -43
  21. package/dist/shared/{language-server.Cqyh6-9S.d.cts → language-server.U2piOAVt.d.cts} +46 -15
  22. package/dist/shared/{language-server.BI99piRy.d.ts → language-server.j-ShR6as.d.ts} +46 -15
  23. package/package.json +10 -10
  24. package/src/ast.ts +1 -0
  25. package/src/formatting/LikeC4Formatter.ts +44 -4
  26. package/src/generated/ast.ts +103 -19
  27. package/src/generated/grammar.ts +1 -1
  28. package/src/generated-lib/icons.ts +0 -1
  29. package/src/like-c4.langium +32 -9
  30. package/src/lsp/CompletionProvider.ts +70 -2
  31. package/src/lsp/SemanticTokenProvider.ts +3 -1
  32. package/src/model/model-builder.ts +13 -7
  33. package/src/model/model-parser.ts +71 -20
  34. package/src/model-graph/compute-view/__test__/fixture.ts +96 -29
  35. package/src/model-graph/compute-view/compute.ts +223 -40
  36. package/src/model-graph/compute-view/predicates.ts +12 -6
  37. package/src/model-graph/utils/applyCustomElementProperties.ts +18 -4
  38. package/src/model-graph/utils/applyCustomRelationProperties.ts +9 -39
  39. package/src/model-graph/utils/applyViewRuleStyles.ts +30 -25
  40. package/src/model-graph/utils/buildComputeNodes.ts +69 -17
  41. package/src/model-graph/utils/elementExpressionToPredicate.ts +3 -1
  42. package/src/model-graph/utils/relationExpressionToPredicates.ts +43 -0
  43. package/src/model-graph/utils/sortNodes.ts +11 -7
  44. package/src/references/scope-computation.ts +3 -2
  45. package/src/validation/index.ts +2 -2
  46. package/src/validation/specification.ts +4 -4
@@ -47,7 +47,7 @@ type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | '
47
47
  type BorderStyleValue = 'none' | LineOptions;
48
48
  type CustomColorId = 'element' | 'model' | ArrowType | ElementShape | LineOptions | string;
49
49
  type CustomColorValue = string;
50
- type DynamicViewRule = DynamicViewIncludePredicate | ViewRuleAutoLayout | ViewRuleGlobalStyle | ViewRuleStyle;
50
+ type DynamicViewRule = DynamicViewIncludePredicate | ViewRuleAutoLayout | ViewRuleStyleOrGlobalRef;
51
51
  declare const DynamicViewRule = "DynamicViewRule";
52
52
  declare function isDynamicViewRule(item: unknown): item is DynamicViewRule;
53
53
  type ElementExpression = ElementDescedantsExpression | ElementKindExpression | ElementRef | ElementTagExpression | ExpandElementExpression | WildcardExpression;
@@ -62,7 +62,7 @@ declare const ElementProperty = "ElementProperty";
62
62
  declare function isElementProperty(item: unknown): item is ElementProperty;
63
63
  type ElementShape = 'browser' | 'cylinder' | 'mobile' | 'person' | 'queue' | 'rectangle' | 'storage';
64
64
  type IconId = string;
65
- type Id = 'element' | 'model' | ArrowType | ElementShape | LineOptions | ThemeColor | string;
65
+ type Id = 'element' | 'group' | 'model' | ArrowType | ElementShape | LineOptions | ThemeColor | string;
66
66
  type LikeC4View = DynamicView | ElementView;
67
67
  declare const LikeC4View = "LikeC4View";
68
68
  declare function isLikeC4View(item: unknown): item is LikeC4View;
@@ -94,11 +94,13 @@ type ViewLayoutDirection = 'BottomTop' | 'LeftRight' | 'RightLeft' | 'TopBottom'
94
94
  type ViewProperty = LinkProperty | ViewStringProperty;
95
95
  declare const ViewProperty = "ViewProperty";
96
96
  declare function isViewProperty(item: unknown): item is ViewProperty;
97
- type ViewRule = ViewRuleAutoLayout | ViewRuleGlobalStyle | ViewRulePredicate | ViewRuleStyle;
97
+ type ViewRule = ViewRuleAutoLayout | ViewRuleGroup | ViewRulePredicate | ViewRuleStyleOrGlobalRef;
98
98
  declare const ViewRule = "ViewRule";
99
99
  declare function isViewRule(item: unknown): item is ViewRule;
100
100
  type ViewRulePredicate = ExcludePredicate | IncludePredicate;
101
101
  declare const ViewRulePredicate = "ViewRulePredicate";
102
+ type ViewRuleStyleOrGlobalRef = ViewRuleGlobalStyle | ViewRuleStyle;
103
+ declare const ViewRuleStyleOrGlobalRef = "ViewRuleStyleOrGlobalRef";
102
104
  type WhereElement = WhereElementKind | WhereElementTag;
103
105
  declare const WhereElement = "WhereElement";
104
106
  type WhereElementExpression = WhereBinaryExpression | WhereElement | WhereElementNegation;
@@ -121,14 +123,14 @@ interface ArrowProperty extends AstNode {
121
123
  }
122
124
  declare const ArrowProperty = "ArrowProperty";
123
125
  interface BorderProperty extends AstNode {
124
- readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
126
+ readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleGroup | ViewRuleStyle;
125
127
  readonly $type: 'BorderProperty';
126
128
  key: 'border';
127
129
  value: BorderStyleValue;
128
130
  }
129
131
  declare const BorderProperty = "BorderProperty";
130
132
  interface ColorProperty extends AstNode {
131
- readonly $container: CustomElementProperties | CustomRelationProperties | ElementStyleProperty | GlobalStyle | RelationStyleProperty | SpecificationRelationshipKind | ViewRuleStyle;
133
+ readonly $container: CustomElementProperties | CustomRelationProperties | ElementStyleProperty | GlobalStyle | RelationStyleProperty | SpecificationRelationshipKind | ViewRuleGroup | ViewRuleStyle;
132
134
  readonly $type: 'ColorProperty';
133
135
  customColor?: Reference<CustomColor>;
134
136
  key: 'color';
@@ -329,7 +331,7 @@ interface ElementViewRef extends AstNode {
329
331
  }
330
332
  declare const ElementViewRef = "ElementViewRef";
331
333
  interface ExcludePredicate extends AstNode {
332
- readonly $container: ElementViewBody;
334
+ readonly $container: ElementViewBody | ViewRuleGroup;
333
335
  readonly $type: 'ExcludePredicate';
334
336
  predicates: Predicates;
335
337
  }
@@ -366,19 +368,33 @@ interface Globals extends AstNode {
366
368
  readonly $container: LikeC4Grammar;
367
369
  readonly $type: 'Globals';
368
370
  name: 'global';
369
- styles: Array<GlobalStyle>;
371
+ styles: Array<GlobalStyle | GlobalStyleGroup>;
370
372
  }
371
373
  declare const Globals = "Globals";
372
374
  declare function isGlobals(item: unknown): item is Globals;
373
375
  interface GlobalStyle extends AstNode {
374
376
  readonly $container: Globals;
375
377
  readonly $type: 'GlobalStyle';
376
- name: string;
378
+ id: GlobalStyleId;
377
379
  props: Array<NotationProperty | StyleProperty>;
378
380
  target: ElementExpressionsIterator;
379
381
  }
380
382
  declare const GlobalStyle = "GlobalStyle";
381
383
  declare function isGlobalStyle(item: unknown): item is GlobalStyle;
384
+ interface GlobalStyleGroup extends AstNode {
385
+ readonly $container: Globals;
386
+ readonly $type: 'GlobalStyleGroup';
387
+ id: GlobalStyleId;
388
+ styles: Array<ViewRuleStyle>;
389
+ }
390
+ declare const GlobalStyleGroup = "GlobalStyleGroup";
391
+ declare function isGlobalStyleGroup(item: unknown): item is GlobalStyleGroup;
392
+ interface GlobalStyleId extends AstNode {
393
+ readonly $container: GlobalStyle | GlobalStyleGroup;
394
+ readonly $type: 'GlobalStyleId';
395
+ name: string;
396
+ }
397
+ declare const GlobalStyleId = "GlobalStyleId";
382
398
  interface IconProperty extends AstNode {
383
399
  readonly $container: CustomElementProperties | ElementBody | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
384
400
  readonly $type: 'IconProperty';
@@ -388,7 +404,7 @@ interface IconProperty extends AstNode {
388
404
  }
389
405
  declare const IconProperty = "IconProperty";
390
406
  interface IncludePredicate extends AstNode {
391
- readonly $container: ElementViewBody;
407
+ readonly $container: ElementViewBody | ViewRuleGroup;
392
408
  readonly $type: 'IncludePredicate';
393
409
  predicates: Predicates;
394
410
  }
@@ -466,7 +482,7 @@ interface ModelViews extends AstNode {
466
482
  readonly $container: LikeC4Grammar;
467
483
  readonly $type: 'ModelViews';
468
484
  name: 'views';
469
- styles: Array<ViewRuleStyle>;
485
+ styles: Array<ViewRuleStyleOrGlobalRef>;
470
486
  views: Array<LikeC4View>;
471
487
  }
472
488
  declare const ModelViews = "ModelViews";
@@ -493,7 +509,7 @@ interface NotesProperty extends AstNode {
493
509
  }
494
510
  declare const NotesProperty = "NotesProperty";
495
511
  interface OpacityProperty extends AstNode {
496
- readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
512
+ readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleGroup | ViewRuleStyle;
497
513
  readonly $type: 'OpacityProperty';
498
514
  key: 'opacity';
499
515
  value: string;
@@ -669,13 +685,21 @@ interface ViewRuleAutoLayout extends AstNode {
669
685
  }
670
686
  declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
671
687
  interface ViewRuleGlobalStyle extends AstNode {
672
- readonly $container: DynamicViewBody | ElementViewBody;
688
+ readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
673
689
  readonly $type: 'ViewRuleGlobalStyle';
674
- style: Reference<GlobalStyle>;
690
+ style: Reference<GlobalStyleId>;
675
691
  }
676
692
  declare const ViewRuleGlobalStyle = "ViewRuleGlobalStyle";
693
+ interface ViewRuleGroup extends AstNode {
694
+ readonly $container: ElementViewBody | ViewRuleGroup;
695
+ readonly $type: 'ViewRuleGroup';
696
+ groupRules: Array<ViewRuleGroup | ViewRulePredicate>;
697
+ props: Array<BorderProperty | ColorProperty | OpacityProperty>;
698
+ title?: string;
699
+ }
700
+ declare const ViewRuleGroup = "ViewRuleGroup";
677
701
  interface ViewRuleStyle extends AstNode {
678
- readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
702
+ readonly $container: DynamicViewBody | ElementViewBody | GlobalStyleGroup | ModelViews;
679
703
  readonly $type: 'ViewRuleStyle';
680
704
  props: Array<NotationProperty | StyleProperty>;
681
705
  target: ElementExpressionsIterator;
@@ -787,6 +811,8 @@ type LikeC4AstType = {
787
811
  ExtendElementBody: ExtendElementBody;
788
812
  FqnElementRef: FqnElementRef;
789
813
  GlobalStyle: GlobalStyle;
814
+ GlobalStyleGroup: GlobalStyleGroup;
815
+ GlobalStyleId: GlobalStyleId;
790
816
  Globals: Globals;
791
817
  IconProperty: IconProperty;
792
818
  InOutRelationExpression: InOutRelationExpression;
@@ -840,8 +866,10 @@ type LikeC4AstType = {
840
866
  ViewRule: ViewRule;
841
867
  ViewRuleAutoLayout: ViewRuleAutoLayout;
842
868
  ViewRuleGlobalStyle: ViewRuleGlobalStyle;
869
+ ViewRuleGroup: ViewRuleGroup;
843
870
  ViewRulePredicate: ViewRulePredicate;
844
871
  ViewRuleStyle: ViewRuleStyle;
872
+ ViewRuleStyleOrGlobalRef: ViewRuleStyleOrGlobalRef;
845
873
  ViewStringProperty: ViewStringProperty;
846
874
  WhereBinaryExpression: WhereBinaryExpression;
847
875
  WhereElement: WhereElement;
@@ -987,7 +1015,7 @@ interface ParsedLikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar
987
1015
  }
988
1016
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
989
1017
  type Guarded<G> = G extends Guard<infer N> ? N : never;
990
- declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isGlobals | typeof isGlobalStyle | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
1018
+ declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isGlobals | typeof isGlobalStyle | typeof isGlobalStyleGroup | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
991
1019
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
992
1020
  declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
993
1021
  isValid: (n: ValidatableAstNode) => boolean;
@@ -1107,6 +1135,7 @@ declare class LikeC4ModelParser {
1107
1135
  private parseElement;
1108
1136
  private parseRelation;
1109
1137
  private parseGlobal;
1138
+ private parseGlobalStyleOrGroup;
1110
1139
  private parseGlobalStyle;
1111
1140
  private parseViews;
1112
1141
  private parseViewRulePredicate;
@@ -1121,7 +1150,9 @@ declare class LikeC4ModelParser {
1121
1150
  private parseRelationPredicateWith;
1122
1151
  private parseRelationExpr;
1123
1152
  private parseViewRule;
1153
+ private parseViewRuleStyleOrGlobalRef;
1124
1154
  private parseViewRuleStyle;
1155
+ private parseViewRuleGroup;
1125
1156
  private parseRuleStyle;
1126
1157
  private parseViewRuleGlobalStyle;
1127
1158
  private parseViewManualLaout;
@@ -47,7 +47,7 @@ type ArrowType = 'crow' | 'diamond' | 'dot' | 'none' | 'normal' | 'odiamond' | '
47
47
  type BorderStyleValue = 'none' | LineOptions;
48
48
  type CustomColorId = 'element' | 'model' | ArrowType | ElementShape | LineOptions | string;
49
49
  type CustomColorValue = string;
50
- type DynamicViewRule = DynamicViewIncludePredicate | ViewRuleAutoLayout | ViewRuleGlobalStyle | ViewRuleStyle;
50
+ type DynamicViewRule = DynamicViewIncludePredicate | ViewRuleAutoLayout | ViewRuleStyleOrGlobalRef;
51
51
  declare const DynamicViewRule = "DynamicViewRule";
52
52
  declare function isDynamicViewRule(item: unknown): item is DynamicViewRule;
53
53
  type ElementExpression = ElementDescedantsExpression | ElementKindExpression | ElementRef | ElementTagExpression | ExpandElementExpression | WildcardExpression;
@@ -62,7 +62,7 @@ declare const ElementProperty = "ElementProperty";
62
62
  declare function isElementProperty(item: unknown): item is ElementProperty;
63
63
  type ElementShape = 'browser' | 'cylinder' | 'mobile' | 'person' | 'queue' | 'rectangle' | 'storage';
64
64
  type IconId = string;
65
- type Id = 'element' | 'model' | ArrowType | ElementShape | LineOptions | ThemeColor | string;
65
+ type Id = 'element' | 'group' | 'model' | ArrowType | ElementShape | LineOptions | ThemeColor | string;
66
66
  type LikeC4View = DynamicView | ElementView;
67
67
  declare const LikeC4View = "LikeC4View";
68
68
  declare function isLikeC4View(item: unknown): item is LikeC4View;
@@ -94,11 +94,13 @@ type ViewLayoutDirection = 'BottomTop' | 'LeftRight' | 'RightLeft' | 'TopBottom'
94
94
  type ViewProperty = LinkProperty | ViewStringProperty;
95
95
  declare const ViewProperty = "ViewProperty";
96
96
  declare function isViewProperty(item: unknown): item is ViewProperty;
97
- type ViewRule = ViewRuleAutoLayout | ViewRuleGlobalStyle | ViewRulePredicate | ViewRuleStyle;
97
+ type ViewRule = ViewRuleAutoLayout | ViewRuleGroup | ViewRulePredicate | ViewRuleStyleOrGlobalRef;
98
98
  declare const ViewRule = "ViewRule";
99
99
  declare function isViewRule(item: unknown): item is ViewRule;
100
100
  type ViewRulePredicate = ExcludePredicate | IncludePredicate;
101
101
  declare const ViewRulePredicate = "ViewRulePredicate";
102
+ type ViewRuleStyleOrGlobalRef = ViewRuleGlobalStyle | ViewRuleStyle;
103
+ declare const ViewRuleStyleOrGlobalRef = "ViewRuleStyleOrGlobalRef";
102
104
  type WhereElement = WhereElementKind | WhereElementTag;
103
105
  declare const WhereElement = "WhereElement";
104
106
  type WhereElementExpression = WhereBinaryExpression | WhereElement | WhereElementNegation;
@@ -121,14 +123,14 @@ interface ArrowProperty extends AstNode {
121
123
  }
122
124
  declare const ArrowProperty = "ArrowProperty";
123
125
  interface BorderProperty extends AstNode {
124
- readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
126
+ readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleGroup | ViewRuleStyle;
125
127
  readonly $type: 'BorderProperty';
126
128
  key: 'border';
127
129
  value: BorderStyleValue;
128
130
  }
129
131
  declare const BorderProperty = "BorderProperty";
130
132
  interface ColorProperty extends AstNode {
131
- readonly $container: CustomElementProperties | CustomRelationProperties | ElementStyleProperty | GlobalStyle | RelationStyleProperty | SpecificationRelationshipKind | ViewRuleStyle;
133
+ readonly $container: CustomElementProperties | CustomRelationProperties | ElementStyleProperty | GlobalStyle | RelationStyleProperty | SpecificationRelationshipKind | ViewRuleGroup | ViewRuleStyle;
132
134
  readonly $type: 'ColorProperty';
133
135
  customColor?: Reference<CustomColor>;
134
136
  key: 'color';
@@ -329,7 +331,7 @@ interface ElementViewRef extends AstNode {
329
331
  }
330
332
  declare const ElementViewRef = "ElementViewRef";
331
333
  interface ExcludePredicate extends AstNode {
332
- readonly $container: ElementViewBody;
334
+ readonly $container: ElementViewBody | ViewRuleGroup;
333
335
  readonly $type: 'ExcludePredicate';
334
336
  predicates: Predicates;
335
337
  }
@@ -366,19 +368,33 @@ interface Globals extends AstNode {
366
368
  readonly $container: LikeC4Grammar;
367
369
  readonly $type: 'Globals';
368
370
  name: 'global';
369
- styles: Array<GlobalStyle>;
371
+ styles: Array<GlobalStyle | GlobalStyleGroup>;
370
372
  }
371
373
  declare const Globals = "Globals";
372
374
  declare function isGlobals(item: unknown): item is Globals;
373
375
  interface GlobalStyle extends AstNode {
374
376
  readonly $container: Globals;
375
377
  readonly $type: 'GlobalStyle';
376
- name: string;
378
+ id: GlobalStyleId;
377
379
  props: Array<NotationProperty | StyleProperty>;
378
380
  target: ElementExpressionsIterator;
379
381
  }
380
382
  declare const GlobalStyle = "GlobalStyle";
381
383
  declare function isGlobalStyle(item: unknown): item is GlobalStyle;
384
+ interface GlobalStyleGroup extends AstNode {
385
+ readonly $container: Globals;
386
+ readonly $type: 'GlobalStyleGroup';
387
+ id: GlobalStyleId;
388
+ styles: Array<ViewRuleStyle>;
389
+ }
390
+ declare const GlobalStyleGroup = "GlobalStyleGroup";
391
+ declare function isGlobalStyleGroup(item: unknown): item is GlobalStyleGroup;
392
+ interface GlobalStyleId extends AstNode {
393
+ readonly $container: GlobalStyle | GlobalStyleGroup;
394
+ readonly $type: 'GlobalStyleId';
395
+ name: string;
396
+ }
397
+ declare const GlobalStyleId = "GlobalStyleId";
382
398
  interface IconProperty extends AstNode {
383
399
  readonly $container: CustomElementProperties | ElementBody | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
384
400
  readonly $type: 'IconProperty';
@@ -388,7 +404,7 @@ interface IconProperty extends AstNode {
388
404
  }
389
405
  declare const IconProperty = "IconProperty";
390
406
  interface IncludePredicate extends AstNode {
391
- readonly $container: ElementViewBody;
407
+ readonly $container: ElementViewBody | ViewRuleGroup;
392
408
  readonly $type: 'IncludePredicate';
393
409
  predicates: Predicates;
394
410
  }
@@ -466,7 +482,7 @@ interface ModelViews extends AstNode {
466
482
  readonly $container: LikeC4Grammar;
467
483
  readonly $type: 'ModelViews';
468
484
  name: 'views';
469
- styles: Array<ViewRuleStyle>;
485
+ styles: Array<ViewRuleStyleOrGlobalRef>;
470
486
  views: Array<LikeC4View>;
471
487
  }
472
488
  declare const ModelViews = "ModelViews";
@@ -493,7 +509,7 @@ interface NotesProperty extends AstNode {
493
509
  }
494
510
  declare const NotesProperty = "NotesProperty";
495
511
  interface OpacityProperty extends AstNode {
496
- readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
512
+ readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleGroup | ViewRuleStyle;
497
513
  readonly $type: 'OpacityProperty';
498
514
  key: 'opacity';
499
515
  value: string;
@@ -669,13 +685,21 @@ interface ViewRuleAutoLayout extends AstNode {
669
685
  }
670
686
  declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
671
687
  interface ViewRuleGlobalStyle extends AstNode {
672
- readonly $container: DynamicViewBody | ElementViewBody;
688
+ readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
673
689
  readonly $type: 'ViewRuleGlobalStyle';
674
- style: Reference<GlobalStyle>;
690
+ style: Reference<GlobalStyleId>;
675
691
  }
676
692
  declare const ViewRuleGlobalStyle = "ViewRuleGlobalStyle";
693
+ interface ViewRuleGroup extends AstNode {
694
+ readonly $container: ElementViewBody | ViewRuleGroup;
695
+ readonly $type: 'ViewRuleGroup';
696
+ groupRules: Array<ViewRuleGroup | ViewRulePredicate>;
697
+ props: Array<BorderProperty | ColorProperty | OpacityProperty>;
698
+ title?: string;
699
+ }
700
+ declare const ViewRuleGroup = "ViewRuleGroup";
677
701
  interface ViewRuleStyle extends AstNode {
678
- readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
702
+ readonly $container: DynamicViewBody | ElementViewBody | GlobalStyleGroup | ModelViews;
679
703
  readonly $type: 'ViewRuleStyle';
680
704
  props: Array<NotationProperty | StyleProperty>;
681
705
  target: ElementExpressionsIterator;
@@ -787,6 +811,8 @@ type LikeC4AstType = {
787
811
  ExtendElementBody: ExtendElementBody;
788
812
  FqnElementRef: FqnElementRef;
789
813
  GlobalStyle: GlobalStyle;
814
+ GlobalStyleGroup: GlobalStyleGroup;
815
+ GlobalStyleId: GlobalStyleId;
790
816
  Globals: Globals;
791
817
  IconProperty: IconProperty;
792
818
  InOutRelationExpression: InOutRelationExpression;
@@ -840,8 +866,10 @@ type LikeC4AstType = {
840
866
  ViewRule: ViewRule;
841
867
  ViewRuleAutoLayout: ViewRuleAutoLayout;
842
868
  ViewRuleGlobalStyle: ViewRuleGlobalStyle;
869
+ ViewRuleGroup: ViewRuleGroup;
843
870
  ViewRulePredicate: ViewRulePredicate;
844
871
  ViewRuleStyle: ViewRuleStyle;
872
+ ViewRuleStyleOrGlobalRef: ViewRuleStyleOrGlobalRef;
845
873
  ViewStringProperty: ViewStringProperty;
846
874
  WhereBinaryExpression: WhereBinaryExpression;
847
875
  WhereElement: WhereElement;
@@ -987,7 +1015,7 @@ interface ParsedLikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar
987
1015
  }
988
1016
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
989
1017
  type Guarded<G> = G extends Guard<infer N> ? N : never;
990
- declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isGlobals | typeof isGlobalStyle | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
1018
+ declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | typeof isGlobals | typeof isGlobalStyle | typeof isGlobalStyleGroup | typeof isDynamicViewPredicateIterator | typeof isElementPredicateWith | typeof isRelationPredicateWith | typeof isElementExpression | typeof isRelationExpression | typeof isDynamicViewParallelSteps | typeof isDynamicViewStep | typeof isViewProperty | typeof isStyleProperty | typeof isTags | typeof isViewRule | typeof isDynamicViewRule | typeof isElementViewBody | typeof isDynamicViewBody | typeof isRelationProperty | typeof isRelationBody | typeof isElementProperty | typeof isElementBody | typeof isExtendElementBody | typeof isSpecificationElementKind | typeof isSpecificationRelationshipKind | typeof isSpecificationTag | typeof isSpecificationColor | typeof isSpecificationRule | typeof isModelViews | typeof isModel>;
991
1019
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
992
1020
  declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
993
1021
  isValid: (n: ValidatableAstNode) => boolean;
@@ -1107,6 +1135,7 @@ declare class LikeC4ModelParser {
1107
1135
  private parseElement;
1108
1136
  private parseRelation;
1109
1137
  private parseGlobal;
1138
+ private parseGlobalStyleOrGroup;
1110
1139
  private parseGlobalStyle;
1111
1140
  private parseViews;
1112
1141
  private parseViewRulePredicate;
@@ -1121,7 +1150,9 @@ declare class LikeC4ModelParser {
1121
1150
  private parseRelationPredicateWith;
1122
1151
  private parseRelationExpr;
1123
1152
  private parseViewRule;
1153
+ private parseViewRuleStyleOrGlobalRef;
1124
1154
  private parseViewRuleStyle;
1155
+ private parseViewRuleGroup;
1125
1156
  private parseRuleStyle;
1126
1157
  private parseViewRuleGlobalStyle;
1127
1158
  private parseViewManualLaout;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@likec4/language-server",
3
3
  "description": "LikeC4 Language Server",
4
- "version": "1.14.0",
4
+ "version": "1.15.1",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -112,8 +112,8 @@
112
112
  },
113
113
  "dependencies": {
114
114
  "@dagrejs/dagre": "^1.1.4",
115
- "@likec4/core": "1.14.0",
116
- "@likec4/log": "1.14.0",
115
+ "@likec4/core": "1.15.1",
116
+ "@likec4/log": "1.15.1",
117
117
  "@msgpack/msgpack": "^3.0.0-beta2",
118
118
  "@smithy/util-base64": "^3.0.0",
119
119
  "fast-equals": "^5.0.1",
@@ -122,7 +122,7 @@
122
122
  "langium": "3.2.0",
123
123
  "object-hash": "^3.0.0",
124
124
  "p-debounce": "^4.0.0",
125
- "remeda": "^2.15.0",
125
+ "remeda": "^2.16.0",
126
126
  "string-hash": "^1.1.3",
127
127
  "strip-indent": "^4.0.0",
128
128
  "type-fest": "4.26.1",
@@ -133,20 +133,20 @@
133
133
  "vscode-uri": "3.0.8"
134
134
  },
135
135
  "devDependencies": {
136
- "@likec4/icons": "1.14.0",
137
- "@likec4/tsconfig": "1.14.0",
138
- "@types/node": "^20.16.5",
136
+ "@likec4/icons": "1.15.1",
137
+ "@likec4/tsconfig": "1.15.1",
138
+ "@types/node": "^20.16.14",
139
139
  "@types/object-hash": "^3.0.6",
140
140
  "@types/string-hash": "^1.1.3",
141
141
  "@vitest/coverage-v8": "^2.1.3",
142
142
  "execa": "^9.3.1",
143
143
  "langium-cli": "3.2.0",
144
- "npm-run-all2": "^6.2.2",
144
+ "npm-run-all2": "^6.2.6",
145
145
  "tsx": "~4.9.3",
146
- "turbo": "^2.1.3",
146
+ "turbo": "^2.2.3",
147
147
  "typescript": "^5.6.3",
148
148
  "unbuild": "^3.0.0-rc.11",
149
149
  "vitest": "^2.1.3"
150
150
  },
151
- "packageManager": "yarn@4.5.0"
151
+ "packageManager": "yarn@4.5.1"
152
152
  }
package/src/ast.ts CHANGED
@@ -236,6 +236,7 @@ function validatableAstNodeGuards<const Predicates extends Guard<AstNode>[]>(
236
236
  const isValidatableAstNode = validatableAstNodeGuards([
237
237
  ast.isGlobals,
238
238
  ast.isGlobalStyle,
239
+ ast.isGlobalStyleGroup,
239
240
  ast.isDynamicViewPredicateIterator,
240
241
  ast.isElementPredicateWith,
241
242
  ast.isRelationPredicateWith,
@@ -17,17 +17,29 @@ export class LikeC4Formatter extends AbstractFormatter {
17
17
  this.removeIndentFromTopLevelStatements(node)
18
18
  this.indentContentInBraces(node)
19
19
 
20
+ // Specification
20
21
  this.formatSpecificationRule(node)
22
+
23
+ // Globals
24
+ this.formatGlobals(node)
25
+
26
+ // Models
21
27
  this.formatElementDeclaration(node)
22
28
  this.formatRelation(node)
29
+ this.formatMetadataProperty(node)
30
+
31
+ // Views
23
32
  this.formatView(node)
24
- this.formatViewRuleStyle(node)
33
+ this.formatViewRuleGroup(node)
34
+ this.formatViewRuleGlobalStyle(node)
25
35
  this.formatIncludeExcludeExpressions(node)
26
36
  this.formatWhereExpression(node)
37
+ this.formatAutolayoutProperty(node)
27
38
  this.formatWithPredicate(node)
39
+
40
+ // Common
41
+ this.formatViewRuleStyle(node)
28
42
  this.formatLeafProperty(node)
29
- this.formatMetadataProperty(node)
30
- this.formatAutolayoutProperty(node)
31
43
  this.formatLinkProperty(node)
32
44
  this.formatNavigateToProperty(node)
33
45
  this.formatTags(node)
@@ -92,9 +104,10 @@ export class LikeC4Formatter extends AbstractFormatter {
92
104
  || ast.isSpecificationRule(node)
93
105
  || ast.isModelViews(node)
94
106
  || ast.isLikeC4Lib(node)
107
+ || ast.isGlobals(node)
95
108
  ) {
96
109
  const formatter = this.getNodeFormatter(node)
97
- formatter.keywords('specification', 'model', 'views', 'likec4lib')
110
+ formatter.keywords('specification', 'model', 'views', 'likec4lib', 'global')
98
111
  .prepend(FormattingOptions.noIndent)
99
112
  }
100
113
  }
@@ -105,6 +118,9 @@ export class LikeC4Formatter extends AbstractFormatter {
105
118
  || ast.isSpecificationRule(node)
106
119
  || ast.isSpecificationElementKind(node)
107
120
  || ast.isSpecificationRelationshipKind(node)
121
+ || ast.isGlobals(node)
122
+ || ast.isGlobalStyle(node)
123
+ || ast.isGlobalStyleGroup(node)
108
124
  || ast.isModel(node)
109
125
  || ast.isElementBody(node)
110
126
  || ast.isExtendElementBody(node)
@@ -115,6 +131,7 @@ export class LikeC4Formatter extends AbstractFormatter {
115
131
  || ast.isElementViewBody(node)
116
132
  || ast.isDynamicViewBody(node)
117
133
  || ast.isViewRuleStyle(node)
134
+ || ast.isViewRuleGroup(node)
118
135
  || ast.isCustomElementProperties(node)
119
136
  || ast.isCustomRelationProperties(node)
120
137
  || ast.isElementStyleProperty(node)
@@ -270,6 +287,17 @@ export class LikeC4Formatter extends AbstractFormatter {
270
287
  })
271
288
  }
272
289
 
290
+ protected formatGlobals(node: AstNode) {
291
+ this.on(node, ast.isGlobalStyle, (n, f) => {
292
+ f.keyword('style').append(FormattingOptions.oneSpace)
293
+ f.property('id').append(FormattingOptions.oneSpace)
294
+ })
295
+
296
+ this.on(node, ast.isGlobalStyleGroup, (n, f) => {
297
+ f.keyword('styleGroup').append(FormattingOptions.oneSpace)
298
+ })
299
+ }
300
+
273
301
  protected formatSpecificationRule(node: AstNode) {
274
302
  if (
275
303
  ast.isSpecificationElementKind(node)
@@ -300,6 +328,18 @@ export class LikeC4Formatter extends AbstractFormatter {
300
328
  }
301
329
  }
302
330
 
331
+ protected formatViewRuleGlobalStyle(node: AstNode) {
332
+ this.on(node, ast.isViewRuleGlobalStyle, (n, f) => {
333
+ f.keywords('global', 'style').append(FormattingOptions.oneSpace)
334
+ })
335
+ }
336
+
337
+ protected formatViewRuleGroup(node: AstNode) {
338
+ this.on(node, ast.isViewRuleGroup, (n, f) => {
339
+ f.keyword('group').append(FormattingOptions.oneSpace)
340
+ })
341
+ }
342
+
303
343
  protected formatViewRuleStyle(node: AstNode) {
304
344
  this.on(node, ast.isViewRuleStyle)
305
345
  ?.keyword('style').append(FormattingOptions.oneSpace)