@likec4/language-server 1.13.0 → 1.15.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 (48) 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.80ITEDo5.cjs} +272 -64
  17. package/dist/shared/{language-server.C2ebP2pZ.cjs → language-server.BUtiWTKg.cjs} +383 -32
  18. package/dist/shared/{language-server.DFLaUdYu.mjs → language-server.DXC9g4_f.mjs} +274 -66
  19. package/dist/shared/{language-server.ryB8CivX.d.mts → language-server.DfMwkd2l.d.mts} +81 -15
  20. package/dist/shared/{language-server.Cnq_hgfm.d.cts → language-server.U2piOAVt.d.cts} +81 -15
  21. package/dist/shared/{language-server.eY70DuKx.d.ts → language-server.j-ShR6as.d.ts} +81 -15
  22. package/dist/shared/{language-server.CrE0nFSB.mjs → language-server.zY53FGJE.mjs} +385 -34
  23. package/package.json +12 -12
  24. package/src/ast.ts +11 -0
  25. package/src/generated/ast.ts +177 -17
  26. package/src/generated/grammar.ts +1 -1
  27. package/src/generated-lib/icons.ts +0 -1
  28. package/src/like-c4.langium +50 -4
  29. package/src/lsp/CompletionProvider.ts +70 -2
  30. package/src/model/model-builder.ts +25 -3
  31. package/src/model/model-parser.ts +150 -33
  32. package/src/model-graph/compute-view/__test__/fixture.ts +45 -4
  33. package/src/model-graph/compute-view/compute.ts +223 -40
  34. package/src/model-graph/compute-view/predicates.ts +12 -6
  35. package/src/model-graph/utils/applyCustomElementProperties.ts +18 -4
  36. package/src/model-graph/utils/applyCustomRelationProperties.ts +2 -1
  37. package/src/model-graph/utils/applyViewRuleStyles.ts +30 -25
  38. package/src/model-graph/utils/buildComputeNodes.ts +69 -17
  39. package/src/model-graph/utils/elementExpressionToPredicate.ts +3 -1
  40. package/src/model-graph/utils/sortNodes.ts +11 -7
  41. package/src/references/scope-computation.ts +24 -1
  42. package/src/validation/index.ts +4 -0
  43. package/src/validation/specification.ts +30 -0
  44. package/src/view-utils/index.ts +1 -0
  45. package/src/view-utils/resolve-global-rules.ts +72 -0
  46. package/dist/shared/language-server.B-9_mDoo.d.mts +0 -1238
  47. package/dist/shared/language-server.C3oS5yhF.d.cts +0 -1238
  48. package/dist/shared/language-server.r5AXAWzc.d.ts +0 -1238
@@ -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 | 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 | 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 | 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 | 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';
@@ -242,7 +244,7 @@ interface ElementDescedantsExpression extends AstNode {
242
244
  }
243
245
  declare const ElementDescedantsExpression = "ElementDescedantsExpression";
244
246
  interface ElementExpressionsIterator extends AstNode {
245
- readonly $container: ElementExpressionsIterator | ViewRuleStyle;
247
+ readonly $container: ElementExpressionsIterator | GlobalStyle | ViewRuleStyle;
246
248
  readonly $type: 'ElementExpressionsIterator';
247
249
  prev?: ElementExpressionsIterator;
248
250
  value: ElementExpression;
@@ -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
  }
@@ -362,8 +364,39 @@ interface FqnElementRef extends AstNode {
362
364
  parent?: FqnElementRef;
363
365
  }
364
366
  declare const FqnElementRef = "FqnElementRef";
367
+ interface Globals extends AstNode {
368
+ readonly $container: LikeC4Grammar;
369
+ readonly $type: 'Globals';
370
+ name: 'global';
371
+ styles: Array<GlobalStyle | GlobalStyleGroup>;
372
+ }
373
+ declare const Globals = "Globals";
374
+ declare function isGlobals(item: unknown): item is Globals;
375
+ interface GlobalStyle extends AstNode {
376
+ readonly $container: Globals;
377
+ readonly $type: 'GlobalStyle';
378
+ id: GlobalStyleId;
379
+ props: Array<NotationProperty | StyleProperty>;
380
+ target: ElementExpressionsIterator;
381
+ }
382
+ declare const GlobalStyle = "GlobalStyle";
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";
365
398
  interface IconProperty extends AstNode {
366
- readonly $container: CustomElementProperties | ElementBody | ElementStyleProperty | ViewRuleStyle;
399
+ readonly $container: CustomElementProperties | ElementBody | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
367
400
  readonly $type: 'IconProperty';
368
401
  key: 'icon';
369
402
  libicon?: Reference<LibIcon>;
@@ -371,7 +404,7 @@ interface IconProperty extends AstNode {
371
404
  }
372
405
  declare const IconProperty = "IconProperty";
373
406
  interface IncludePredicate extends AstNode {
374
- readonly $container: ElementViewBody;
407
+ readonly $container: ElementViewBody | ViewRuleGroup;
375
408
  readonly $type: 'IncludePredicate';
376
409
  predicates: Predicates;
377
410
  }
@@ -396,6 +429,7 @@ interface LibIcon extends AstNode {
396
429
  declare const LibIcon = "LibIcon";
397
430
  interface LikeC4Grammar extends AstNode {
398
431
  readonly $type: 'LikeC4Grammar';
432
+ globals: Array<Globals>;
399
433
  likec4lib: Array<LikeC4Lib>;
400
434
  models: Array<Model>;
401
435
  specifications: Array<SpecificationRule>;
@@ -448,7 +482,7 @@ interface ModelViews extends AstNode {
448
482
  readonly $container: LikeC4Grammar;
449
483
  readonly $type: 'ModelViews';
450
484
  name: 'views';
451
- styles: Array<ViewRuleStyle>;
485
+ styles: Array<ViewRuleStyleOrGlobalRef>;
452
486
  views: Array<LikeC4View>;
453
487
  }
454
488
  declare const ModelViews = "ModelViews";
@@ -461,7 +495,7 @@ interface NavigateToProperty extends AstNode {
461
495
  }
462
496
  declare const NavigateToProperty = "NavigateToProperty";
463
497
  interface NotationProperty extends AstNode {
464
- readonly $container: CustomElementProperties | CustomRelationProperties | ViewRuleStyle;
498
+ readonly $container: CustomElementProperties | CustomRelationProperties | GlobalStyle | ViewRuleStyle;
465
499
  readonly $type: 'NotationProperty';
466
500
  key: 'notation';
467
501
  value: string;
@@ -475,7 +509,7 @@ interface NotesProperty extends AstNode {
475
509
  }
476
510
  declare const NotesProperty = "NotesProperty";
477
511
  interface OpacityProperty extends AstNode {
478
- readonly $container: CustomElementProperties | ElementStyleProperty | ViewRuleStyle;
512
+ readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleGroup | ViewRuleStyle;
479
513
  readonly $type: 'OpacityProperty';
480
514
  key: 'opacity';
481
515
  value: string;
@@ -560,7 +594,7 @@ interface RelationStyleProperty extends AstNode {
560
594
  }
561
595
  declare const RelationStyleProperty = "RelationStyleProperty";
562
596
  interface ShapeProperty extends AstNode {
563
- readonly $container: CustomElementProperties | ElementStyleProperty | ViewRuleStyle;
597
+ readonly $container: CustomElementProperties | ElementStyleProperty | GlobalStyle | ViewRuleStyle;
564
598
  readonly $type: 'ShapeProperty';
565
599
  key: 'shape';
566
600
  value: ElementShape;
@@ -650,8 +684,22 @@ interface ViewRuleAutoLayout extends AstNode {
650
684
  rankSep?: number;
651
685
  }
652
686
  declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
653
- interface ViewRuleStyle extends AstNode {
687
+ interface ViewRuleGlobalStyle extends AstNode {
654
688
  readonly $container: DynamicViewBody | ElementViewBody | ModelViews;
689
+ readonly $type: 'ViewRuleGlobalStyle';
690
+ style: Reference<GlobalStyleId>;
691
+ }
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";
701
+ interface ViewRuleStyle extends AstNode {
702
+ readonly $container: DynamicViewBody | ElementViewBody | GlobalStyleGroup | ModelViews;
655
703
  readonly $type: 'ViewRuleStyle';
656
704
  props: Array<NotationProperty | StyleProperty>;
657
705
  target: ElementExpressionsIterator;
@@ -762,6 +810,10 @@ type LikeC4AstType = {
762
810
  ExtendElement: ExtendElement;
763
811
  ExtendElementBody: ExtendElementBody;
764
812
  FqnElementRef: FqnElementRef;
813
+ GlobalStyle: GlobalStyle;
814
+ GlobalStyleGroup: GlobalStyleGroup;
815
+ GlobalStyleId: GlobalStyleId;
816
+ Globals: Globals;
765
817
  IconProperty: IconProperty;
766
818
  InOutRelationExpression: InOutRelationExpression;
767
819
  IncludePredicate: IncludePredicate;
@@ -813,8 +865,11 @@ type LikeC4AstType = {
813
865
  ViewRef: ViewRef;
814
866
  ViewRule: ViewRule;
815
867
  ViewRuleAutoLayout: ViewRuleAutoLayout;
868
+ ViewRuleGlobalStyle: ViewRuleGlobalStyle;
869
+ ViewRuleGroup: ViewRuleGroup;
816
870
  ViewRulePredicate: ViewRulePredicate;
817
871
  ViewRuleStyle: ViewRuleStyle;
872
+ ViewRuleStyleOrGlobalRef: ViewRuleStyleOrGlobalRef;
818
873
  ViewStringProperty: ViewStringProperty;
819
874
  WhereBinaryExpression: WhereBinaryExpression;
820
875
  WhereElement: WhereElement;
@@ -905,6 +960,9 @@ interface ParsedAstRelation {
905
960
  [key: string]: string;
906
961
  };
907
962
  }
963
+ interface ParsedAstGlobals {
964
+ styles: Record<c4.GlobalStyleID, c4.NonEmptyArray<c4.ViewRuleStyle>>;
965
+ }
908
966
  interface ParsedAstElementView {
909
967
  __: 'element';
910
968
  id: c4.ViewID;
@@ -945,6 +1003,7 @@ interface LikeC4DocumentProps {
945
1003
  c4Specification?: ParsedAstSpecification;
946
1004
  c4Elements?: ParsedAstElement[];
947
1005
  c4Relations?: ParsedAstRelation[];
1006
+ c4Globals?: ParsedAstGlobals;
948
1007
  c4Views?: ParsedAstView[];
949
1008
  c4fqnIndex?: MultiMap<c4.Fqn, DocFqnIndexAstNodeDescription>;
950
1009
  }
@@ -956,7 +1015,7 @@ interface ParsedLikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar
956
1015
  }
957
1016
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
958
1017
  type Guarded<G> = G extends Guard<infer N> ? N : never;
959
- declare const isValidatableAstNode: (n: AstNode) => n is Guarded<typeof isLikeC4View | typeof isRelation | typeof isExtendElement | typeof isElement | 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>;
960
1019
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
961
1020
  declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
962
1021
  isValid: (n: ValidatableAstNode) => boolean;
@@ -1075,6 +1134,9 @@ declare class LikeC4ModelParser {
1075
1134
  private parseModel;
1076
1135
  private parseElement;
1077
1136
  private parseRelation;
1137
+ private parseGlobal;
1138
+ private parseGlobalStyleOrGroup;
1139
+ private parseGlobalStyle;
1078
1140
  private parseViews;
1079
1141
  private parseViewRulePredicate;
1080
1142
  private parsePredicate;
@@ -1088,8 +1150,11 @@ declare class LikeC4ModelParser {
1088
1150
  private parseRelationPredicateWith;
1089
1151
  private parseRelationExpr;
1090
1152
  private parseViewRule;
1153
+ private parseViewRuleStyleOrGlobalRef;
1091
1154
  private parseViewRuleStyle;
1155
+ private parseViewRuleGroup;
1092
1156
  private parseRuleStyle;
1157
+ private parseViewRuleGlobalStyle;
1093
1158
  private parseViewManualLaout;
1094
1159
  private parseDynamicParallelSteps;
1095
1160
  private parseDynamicStep;
@@ -1120,6 +1185,7 @@ type ElementsContainer = Model | ElementBody | ExtendElementBody;
1120
1185
  declare class LikeC4ScopeComputation extends DefaultScopeComputation {
1121
1186
  computeExports(document: LikeC4LangiumDocument, _cancelToken?: CancellationToken): Promise<AstNodeDescription[]>;
1122
1187
  private exportViews;
1188
+ private exportGlobals;
1123
1189
  private exportModel;
1124
1190
  private exportLibrary;
1125
1191
  private exportSpecification;