@likec4/language-server 1.9.0 → 1.10.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 +1 -1
  4. package/dist/browser.d.mts +1 -1
  5. package/dist/browser.d.ts +1 -1
  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 +1 -1
  16. package/dist/node.d.mts +1 -1
  17. package/dist/node.d.ts +1 -1
  18. package/dist/node.mjs +1 -1
  19. package/dist/shared/{language-server.86lmJ8ZN.d.cts → language-server.CjFzaJwI.d.cts} +42 -13
  20. package/dist/shared/{language-server.RjhrBZS0.d.ts → language-server.CtKHXJDD.d.ts} +42 -13
  21. package/dist/shared/{language-server.CFTY6j4e.d.mts → language-server.D-84I33F.d.mts} +42 -13
  22. package/dist/shared/{language-server.Q-wtPShM.mjs → language-server.DBJJUUgF.mjs} +485 -108
  23. package/dist/shared/{language-server.CCB4ESN5.mjs → language-server.DtBRb9os.mjs} +166 -116
  24. package/dist/shared/{language-server.D0bOlrCi.cjs → language-server.DwyCJvXm.cjs} +164 -114
  25. package/dist/shared/{language-server.B1TZgyoH.cjs → language-server.JWkqVjGv.cjs} +481 -104
  26. package/package.json +6 -5
  27. package/src/ast.ts +8 -6
  28. package/src/formatting/LikeC4Formatter.ts +388 -0
  29. package/src/formatting/utils.ts +26 -0
  30. package/src/generated/ast.ts +104 -10
  31. package/src/generated/grammar.ts +1 -1
  32. package/src/like-c4.langium +34 -7
  33. package/src/lsp/DocumentLinkProvider.ts +27 -15
  34. package/src/lsp/SemanticTokenProvider.ts +1 -1
  35. package/src/lsp/index.ts +1 -1
  36. package/src/model/fqn-index.ts +0 -1
  37. package/src/model/model-builder.ts +43 -32
  38. package/src/model/model-parser.ts +43 -21
  39. package/src/model-graph/compute-view/compute.ts +104 -78
  40. package/src/model-graph/compute-view/predicates.ts +3 -5
  41. package/src/model-graph/dynamic-view/compute.ts +96 -60
  42. package/src/model-graph/utils/buildElementNotations.ts +1 -1
  43. package/src/module.ts +6 -9
  44. package/src/test/testServices.ts +27 -7
  45. package/src/validation/index.ts +2 -1
  46. package/src/validation/property-checks.ts +13 -1
  47. package/src/validation/specification.ts +3 -3
  48. package/src/view-utils/resolve-relative-paths.ts +14 -17
@@ -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+/,
@@ -169,7 +170,7 @@ export function isRelationPredicateOrWhere(item: unknown): item is RelationPredi
169
170
  return reflection.isInstance(item, RelationPredicateOrWhere);
170
171
  }
171
172
 
172
- export type RelationProperty = LinkProperty | MetadataProperty | RelationStringProperty | RelationStyleProperty;
173
+ export type RelationProperty = LinkProperty | MetadataProperty | RelationNavigateToProperty | RelationStringProperty | RelationStyleProperty;
173
174
 
174
175
  export const RelationProperty = 'RelationProperty';
175
176
 
@@ -185,7 +186,7 @@ export function isRelationshipStyleProperty(item: unknown): item is Relationship
185
186
  return reflection.isInstance(item, RelationshipStyleProperty);
186
187
  }
187
188
 
188
- export type StringProperty = ElementStringProperty | MetadataAttribute | NotationProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
189
+ export type StringProperty = ElementStringProperty | MetadataAttribute | NotationProperty | NotesProperty | RelationStringProperty | SpecificationElementStringProperty | SpecificationRelationshipStringProperty | ViewStringProperty;
189
190
 
190
191
  export const StringProperty = 'StringProperty';
191
192
 
@@ -372,7 +373,7 @@ export function isCustomElementProperties(item: unknown): item is CustomElementP
372
373
  export interface CustomRelationProperties extends AstNode {
373
374
  readonly $container: DynamicViewStep | RelationPredicateWith;
374
375
  readonly $type: 'CustomRelationProperties';
375
- props: Array<NotationProperty | RelationStringProperty | RelationshipStyleProperty>;
376
+ props: Array<NotationProperty | NotesProperty | RelationNavigateToProperty | RelationStringProperty | RelationshipStyleProperty>;
376
377
  }
377
378
 
378
379
  export const CustomRelationProperties = 'CustomRelationProperties';
@@ -412,7 +413,7 @@ export interface DynamicViewBody extends AstNode {
412
413
  readonly $type: 'DynamicViewBody';
413
414
  props: Array<ViewProperty>;
414
415
  rules: Array<DynamicViewRule>;
415
- steps: Array<DynamicViewStep>;
416
+ steps: Array<DynamicViewParallelSteps | DynamicViewStep>;
416
417
  tags?: Tags;
417
418
  }
418
419
 
@@ -434,6 +435,18 @@ export function isDynamicViewIncludePredicate(item: unknown): item is DynamicVie
434
435
  return reflection.isInstance(item, DynamicViewIncludePredicate);
435
436
  }
436
437
 
438
+ export interface DynamicViewParallelSteps extends AstNode {
439
+ readonly $container: DynamicViewBody;
440
+ readonly $type: 'DynamicViewParallelSteps';
441
+ steps: Array<DynamicViewStep>;
442
+ }
443
+
444
+ export const DynamicViewParallelSteps = 'DynamicViewParallelSteps';
445
+
446
+ export function isDynamicViewParallelSteps(item: unknown): item is DynamicViewParallelSteps {
447
+ return reflection.isInstance(item, DynamicViewParallelSteps);
448
+ }
449
+
437
450
  export interface DynamicViewPredicateIterator extends AstNode {
438
451
  readonly $container: DynamicViewIncludePredicate | DynamicViewPredicateIterator;
439
452
  readonly $type: 'DynamicViewPredicateIterator';
@@ -447,8 +460,20 @@ export function isDynamicViewPredicateIterator(item: unknown): item is DynamicVi
447
460
  return reflection.isInstance(item, DynamicViewPredicateIterator);
448
461
  }
449
462
 
463
+ export interface DynamicViewRef extends AstNode {
464
+ readonly $container: RelationNavigateToProperty;
465
+ readonly $type: 'DynamicViewRef';
466
+ view: Reference<DynamicView>;
467
+ }
468
+
469
+ export const DynamicViewRef = 'DynamicViewRef';
470
+
471
+ export function isDynamicViewRef(item: unknown): item is DynamicViewRef {
472
+ return reflection.isInstance(item, DynamicViewRef);
473
+ }
474
+
450
475
  export interface DynamicViewStep extends AstNode {
451
- readonly $container: DynamicViewBody;
476
+ readonly $container: DynamicViewBody | DynamicViewParallelSteps;
452
477
  readonly $type: 'DynamicViewStep';
453
478
  custom?: CustomRelationProperties;
454
479
  isBackward: boolean;
@@ -916,6 +941,19 @@ export function isNotationProperty(item: unknown): item is NotationProperty {
916
941
  return reflection.isInstance(item, NotationProperty);
917
942
  }
918
943
 
944
+ export interface NotesProperty extends AstNode {
945
+ readonly $container: CustomRelationProperties;
946
+ readonly $type: 'NotesProperty';
947
+ key: 'notes';
948
+ value: string;
949
+ }
950
+
951
+ export const NotesProperty = 'NotesProperty';
952
+
953
+ export function isNotesProperty(item: unknown): item is NotesProperty {
954
+ return reflection.isInstance(item, NotesProperty);
955
+ }
956
+
919
957
  export interface OpacityProperty extends AstNode {
920
958
  readonly $container: CustomElementProperties | ElementStyleProperty | ViewRuleStyle;
921
959
  readonly $type: 'OpacityProperty';
@@ -987,6 +1025,19 @@ export function isRelationBody(item: unknown): item is RelationBody {
987
1025
  return reflection.isInstance(item, RelationBody);
988
1026
  }
989
1027
 
1028
+ export interface RelationNavigateToProperty extends AstNode {
1029
+ readonly $container: CustomRelationProperties | RelationBody;
1030
+ readonly $type: 'RelationNavigateToProperty';
1031
+ key: 'navigateTo';
1032
+ value: DynamicViewRef;
1033
+ }
1034
+
1035
+ export const RelationNavigateToProperty = 'RelationNavigateToProperty';
1036
+
1037
+ export function isRelationNavigateToProperty(item: unknown): item is RelationNavigateToProperty {
1038
+ return reflection.isInstance(item, RelationNavigateToProperty);
1039
+ }
1040
+
990
1041
  export interface RelationPredicateWhere extends AstNode {
991
1042
  readonly $container: Predicates | RelationPredicateWith;
992
1043
  readonly $type: 'RelationPredicateWhere';
@@ -1349,7 +1400,9 @@ export type LikeC4AstType = {
1349
1400
  DynamicView: DynamicView
1350
1401
  DynamicViewBody: DynamicViewBody
1351
1402
  DynamicViewIncludePredicate: DynamicViewIncludePredicate
1403
+ DynamicViewParallelSteps: DynamicViewParallelSteps
1352
1404
  DynamicViewPredicateIterator: DynamicViewPredicateIterator
1405
+ DynamicViewRef: DynamicViewRef
1353
1406
  DynamicViewRule: DynamicViewRule
1354
1407
  DynamicViewStep: DynamicViewStep
1355
1408
  Element: Element
@@ -1393,6 +1446,7 @@ export type LikeC4AstType = {
1393
1446
  ModelViews: ModelViews
1394
1447
  NavigateToProperty: NavigateToProperty
1395
1448
  NotationProperty: NotationProperty
1449
+ NotesProperty: NotesProperty
1396
1450
  OpacityProperty: OpacityProperty
1397
1451
  OutgoingRelationExpression: OutgoingRelationExpression
1398
1452
  Predicate: Predicate
@@ -1400,6 +1454,7 @@ export type LikeC4AstType = {
1400
1454
  Relation: Relation
1401
1455
  RelationBody: RelationBody
1402
1456
  RelationExpression: RelationExpression
1457
+ RelationNavigateToProperty: RelationNavigateToProperty
1403
1458
  RelationPredicate: RelationPredicate
1404
1459
  RelationPredicateOrWhere: RelationPredicateOrWhere
1405
1460
  RelationPredicateWhere: RelationPredicateWhere
@@ -1448,7 +1503,7 @@ export type LikeC4AstType = {
1448
1503
  export class LikeC4AstReflection extends AbstractAstReflection {
1449
1504
 
1450
1505
  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];
1506
+ 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
1507
  }
1453
1508
 
1454
1509
  protected override computeIsSubtype(subtype: string, supertype: string): boolean {
@@ -1516,6 +1571,7 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1516
1571
  }
1517
1572
  case MetadataAttribute:
1518
1573
  case NotationProperty:
1574
+ case NotesProperty:
1519
1575
  case SpecificationElementStringProperty:
1520
1576
  case SpecificationRelationshipStringProperty: {
1521
1577
  return this.isSubtype(StringProperty, supertype);
@@ -1530,6 +1586,10 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1530
1586
  case RelationPredicateWhere: {
1531
1587
  return this.isSubtype(RelationPredicateOrWhere, supertype);
1532
1588
  }
1589
+ case RelationNavigateToProperty:
1590
+ case RelationStyleProperty: {
1591
+ return this.isSubtype(RelationProperty, supertype);
1592
+ }
1533
1593
  case RelationPredicateOrWhere:
1534
1594
  case RelationPredicateWith: {
1535
1595
  return this.isSubtype(RelationPredicate, supertype);
@@ -1537,9 +1597,6 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1537
1597
  case RelationStringProperty: {
1538
1598
  return this.isSubtype(RelationProperty, supertype) || this.isSubtype(StringProperty, supertype);
1539
1599
  }
1540
- case RelationStyleProperty: {
1541
- return this.isSubtype(RelationProperty, supertype);
1542
- }
1543
1600
  case ViewRuleAutoLayout:
1544
1601
  case ViewRuleStyle: {
1545
1602
  return this.isSubtype(DynamicViewRule, supertype) || this.isSubtype(ViewRule, supertype);
@@ -1589,6 +1646,9 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1589
1646
  case 'ColorProperty:customColor': {
1590
1647
  return CustomColor;
1591
1648
  }
1649
+ case 'DynamicViewRef:view': {
1650
+ return DynamicView;
1651
+ }
1592
1652
  case 'DynamicViewStep:kind':
1593
1653
  case 'OutgoingRelationExpression:kind':
1594
1654
  case 'Relation:kind':
@@ -1716,6 +1776,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1716
1776
  ]
1717
1777
  };
1718
1778
  }
1779
+ case DynamicViewParallelSteps: {
1780
+ return {
1781
+ name: DynamicViewParallelSteps,
1782
+ properties: [
1783
+ { name: 'steps', defaultValue: [] }
1784
+ ]
1785
+ };
1786
+ }
1719
1787
  case DynamicViewPredicateIterator: {
1720
1788
  return {
1721
1789
  name: DynamicViewPredicateIterator,
@@ -1725,6 +1793,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
1725
1793
  ]
1726
1794
  };
1727
1795
  }
1796
+ case DynamicViewRef: {
1797
+ return {
1798
+ name: DynamicViewRef,
1799
+ properties: [
1800
+ { name: 'view' }
1801
+ ]
1802
+ };
1803
+ }
1728
1804
  case DynamicViewStep: {
1729
1805
  return {
1730
1806
  name: DynamicViewStep,
@@ -2051,6 +2127,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
2051
2127
  ]
2052
2128
  };
2053
2129
  }
2130
+ case NotesProperty: {
2131
+ return {
2132
+ name: NotesProperty,
2133
+ properties: [
2134
+ { name: 'key' },
2135
+ { name: 'value' }
2136
+ ]
2137
+ };
2138
+ }
2054
2139
  case OpacityProperty: {
2055
2140
  return {
2056
2141
  name: OpacityProperty,
@@ -2102,6 +2187,15 @@ export class LikeC4AstReflection extends AbstractAstReflection {
2102
2187
  ]
2103
2188
  };
2104
2189
  }
2190
+ case RelationNavigateToProperty: {
2191
+ return {
2192
+ name: RelationNavigateToProperty,
2193
+ properties: [
2194
+ { name: 'key' },
2195
+ { name: 'value' }
2196
+ ]
2197
+ };
2198
+ }
2105
2199
  case RelationPredicateWhere: {
2106
2200
  return {
2107
2201
  name: RelationPredicateWhere,