@likec4/language-server 1.19.1 → 1.20.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.
@@ -413,11 +413,13 @@ WhereRelationNegation:
413
413
 
414
414
  WhereRelation:
415
415
  {infer WhereRelationTag} 'tag' EqOperator value=[Tag:TagId]? |
416
- {infer WhereRelationKind} 'kind' EqOperator value=[RelationshipKind:Id]?
416
+ {infer WhereRelationKind} 'kind' EqOperator value=[RelationshipKind:Id]? |
417
+ {infer WhereRelationParticipantTag} participant=Participant StickyDot 'tag' EqOperator value=[Tag:TagId]? |
418
+ {infer WhereRelationParticipantKind} participant=Participant StickyDot 'kind' EqOperator value=[DeploymentNodeOrElementKind:Id]?
417
419
  ;
418
-
419
- type WhereTagEqual = WhereElementTag | WhereRelationTag;
420
- type WhereKindEqual = WhereElementKind | WhereRelationKind;
420
+ type DeploymentNodeOrElementKind = ElementKind | DeploymentNodeKind
421
+ type WhereTagEqual = WhereElementTag | WhereRelationTag | WhereRelationParticipantTag;
422
+ type WhereKindEqual = WhereElementKind | WhereRelationKind | WhereRelationParticipantKind;
421
423
 
422
424
  type WhereExpression = WhereElementExpression | WhereRelationExpression;
423
425
 
@@ -620,10 +622,13 @@ DeploymentViewRulePredicateExpression:
620
622
  ;
621
623
 
622
624
  ExpressionV2:
623
- RelationExpr |
625
+ RelationPredicateOrWhereV2 |
624
626
  FqnExpr
625
627
  ;
626
628
 
629
+ RelationPredicateOrWhereV2:
630
+ RelationExpr ({infer RelationPredicateWhereV2.subject=current} 'where' where=WhereRelationExpression?)?
631
+ ;
627
632
 
628
633
  FqnExpr:
629
634
  {infer WildcardExpression} isWildcard?='*' |
@@ -766,6 +771,8 @@ ThemeColor returns string:
766
771
  'primary' | 'secondary' | 'muted' | 'slate' | 'blue' | 'indigo' | 'sky' | 'red' | 'gray' | 'green' | 'amber';
767
772
  ElementShape returns string:
768
773
  'rectangle' | 'person' | 'browser' | 'mobile' | 'cylinder' | 'storage' | 'queue';
774
+ Participant returns string:
775
+ 'source' | 'target';
769
776
 
770
777
  CustomColorValue returns string:
771
778
  Hash (Id | Hex | Number);
@@ -786,7 +793,7 @@ CustomColorId returns string:
786
793
  IdTerminal | ElementShape | ArrowType | LineOptions | 'element' | 'model';
787
794
 
788
795
  Id returns string:
789
- IdTerminal | ElementShape | ThemeColor | ArrowType | LineOptions | 'element' | 'model' | 'group' | 'node' | 'deployment' | 'instance';
796
+ IdTerminal | ElementShape | ThemeColor | ArrowType | LineOptions | Participant | 'element' | 'model' | 'group' | 'node' | 'deployment' | 'instance';
790
797
 
791
798
  fragment EqOperator:
792
799
  (
@@ -1,5 +1,5 @@
1
1
  import type { AstNode } from 'langium';
2
- import { AbstractSemanticTokenProvider, type SemanticTokenAcceptor } from 'langium/lsp';
2
+ import { type SemanticTokenAcceptor, AbstractSemanticTokenProvider } from 'langium/lsp';
3
3
  export declare class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
4
4
  protected highlightElement(node: AstNode, acceptor: SemanticTokenAcceptor): void | undefined | 'prune';
5
5
  private highlightNameAndKind;
@@ -118,6 +118,13 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
118
118
  });
119
119
  return;
120
120
  }
121
+ if (ast.isWhereRelationParticipantKind(node) || ast.isWhereRelationParticipantTag(node)) {
122
+ acceptor({
123
+ node,
124
+ property: "participant",
125
+ type: SemanticTokenTypes.keyword
126
+ });
127
+ }
121
128
  if (ast.isElementKindExpression(node) && isTruthy(node.kind)) {
122
129
  acceptor({
123
130
  node,
@@ -14,21 +14,27 @@ const parseEquals = ({ operator, not }, value) => {
14
14
  }
15
15
  return not ? { neq: value } : { eq: value };
16
16
  };
17
+ function parseParticipant(astNode) {
18
+ if (!ast.isWhereRelationParticipantKind(astNode) && !ast.isWhereRelationParticipantTag(astNode)) {
19
+ return null;
20
+ }
21
+ return astNode.participant;
22
+ }
17
23
  export function parseWhereClause(astNode) {
18
24
  switch (true) {
19
25
  case ast.isWhereTagEqual(astNode): {
20
26
  const tag = astNode.value?.ref?.name;
27
+ const participant = parseParticipant(astNode);
21
28
  invariant(tag, "Expected tag name");
22
- return {
23
- tag: parseEquals(astNode, tag)
24
- };
29
+ const tagOperator = { tag: parseEquals(astNode, tag) };
30
+ return participant ? { participant, operator: tagOperator } : tagOperator;
25
31
  }
26
32
  case ast.isWhereKindEqual(astNode): {
27
33
  const kind = astNode.value?.ref?.name;
34
+ const participant = parseParticipant(astNode);
28
35
  invariant(kind, "Expected kind name");
29
- return {
30
- kind: parseEquals(astNode, kind)
31
- };
36
+ const kindOperator = { kind: parseEquals(astNode, kind) };
37
+ return participant ? { participant, operator: kindOperator } : kindOperator;
32
38
  }
33
39
  case (ast.isWhereElementNegation(astNode) || ast.isWhereRelationNegation(astNode)): {
34
40
  return {
@@ -60,6 +60,7 @@ declare const DocumentParserFromMixins: {
60
60
  parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
61
61
  parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
62
62
  parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
63
+ parseRelationWhereExpr(astNode: import("../generated/ast").RelationPredicateWhereV2): invariant;
63
64
  parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
64
65
  parseDeployment(): void;
65
66
  parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
@@ -117,6 +118,7 @@ declare const DocumentParserFromMixins: {
117
118
  parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
118
119
  parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
119
120
  parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
121
+ parseRelationWhereExpr(astNode: import("../generated/ast").RelationPredicateWhereV2): invariant;
120
122
  parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
121
123
  parseDeployment(): void;
122
124
  parseDeploymentNode(astNode: import("../generated/ast").DeploymentNode): import("../ast").ParsedAstDeployment.Node;
@@ -183,6 +185,7 @@ declare const DocumentParserFromMixins: {
183
185
  parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
184
186
  parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
185
187
  parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
188
+ parseRelationWhereExpr(astNode: import("../generated/ast").RelationPredicateWhereV2): invariant;
186
189
  parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
187
190
  isValid: import("../validation").IsValidFn;
188
191
  readonly services: LikeC4Services;
@@ -215,6 +218,7 @@ declare const DocumentParserFromMixins: {
215
218
  parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
216
219
  parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
217
220
  parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
221
+ parseRelationWhereExpr(astNode: import("../generated/ast").RelationPredicateWhereV2): invariant;
218
222
  parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
219
223
  isValid: import("../validation").IsValidFn;
220
224
  readonly services: LikeC4Services;
@@ -261,6 +265,7 @@ declare const DocumentParserFromMixins: {
261
265
  parseFqnExpr(astNode: import("../generated/ast").FqnExpr): invariant;
262
266
  parseFqnRefExpr(astNode: import("../generated/ast").FqnRefExpr): invariant;
263
267
  parseFqnExpressions(astNode: import("../generated/ast").FqnExpressions): invariant[];
268
+ parseRelationWhereExpr(astNode: import("../generated/ast").RelationPredicateWhereV2): invariant;
264
269
  parseRelationExpr(astNode: import("../generated/ast").RelationExpr): invariant;
265
270
  isValid: import("../validation").IsValidFn;
266
271
  readonly services: LikeC4Services;
@@ -12,6 +12,7 @@ export declare function DeploymentModelParser<TBase extends WithExpressionV2>(B:
12
12
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
13
13
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
14
14
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
15
+ parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
15
16
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
16
17
  isValid: import("../../validation").IsValidFn;
17
18
  readonly services: import("../..").LikeC4Services;
@@ -1,5 +1,5 @@
1
1
  import type * as c4 from '@likec4/core';
2
- import { ast, type ParsedAstDeploymentView } from '../../ast';
2
+ import { type ParsedAstDeploymentView, ast } from '../../ast';
3
3
  import type { WithDeploymentModel } from './DeploymentModelParser';
4
4
  import type { WithExpressionV2 } from './FqnRefParser';
5
5
  export type WithDeploymentView = ReturnType<typeof DeploymentViewParser>;
@@ -13,6 +13,7 @@ export declare function DeploymentViewParser<TBase extends WithExpressionV2 & Wi
13
13
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
14
14
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
15
15
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
16
+ parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
16
17
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
17
18
  isValid: import("../../validation").IsValidFn;
18
19
  readonly services: import("../..").LikeC4Services;
@@ -70,6 +70,9 @@ export function DeploymentViewParser(B) {
70
70
  case ast.isRelationExpr(expr):
71
71
  exprs.unshift(this.parseRelationExpr(expr));
72
72
  break;
73
+ case ast.isRelationPredicateWhereV2(expr):
74
+ exprs.unshift(this.parseRelationWhereExpr(expr));
75
+ break;
73
76
  default:
74
77
  nonexhaustive(expr);
75
78
  }
@@ -8,6 +8,7 @@ export declare function ExpressionV2Parser<TBase extends Base>(B: TBase): {
8
8
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
9
9
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
10
10
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
11
+ parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
11
12
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
12
13
  isValid: import("../../validation").IsValidFn;
13
14
  readonly services: import("../..").LikeC4Services;
@@ -3,6 +3,7 @@ import { isNonNullish } from "remeda";
3
3
  import { ast } from "../../ast.js";
4
4
  import { logWarnError } from "../../logger.js";
5
5
  import { instanceRef } from "../../utils/fqnRef.js";
6
+ import { parseWhereClause } from "../model-parser-where.js";
6
7
  export function ExpressionV2Parser(B) {
7
8
  return class ExpressionV2Parser extends B {
8
9
  parseFqnRef(astNode) {
@@ -79,7 +80,19 @@ export function ExpressionV2Parser(B) {
79
80
  }
80
81
  return exprs.reverse();
81
82
  }
83
+ parseRelationWhereExpr(astNode) {
84
+ return {
85
+ where: {
86
+ expr: this.parseRelationExpr(astNode.subject),
87
+ condition: astNode.where ? parseWhereClause(astNode.where) : {
88
+ kind: { neq: "--always-true--" }
89
+ }
90
+ }
91
+ };
92
+ }
82
93
  parseRelationExpr(astNode) {
94
+ if (ast.isRelationPredicateWhere(astNode)) {
95
+ }
83
96
  if (ast.isDirectedRelationExpr(astNode)) {
84
97
  return {
85
98
  source: this.parseFqnExpr(astNode.source.from),
@@ -57,6 +57,7 @@ export declare function GlobalsParser<TBase extends WithViewsParser>(B: TBase):
57
57
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
58
58
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
59
59
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
60
+ parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
60
61
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
61
62
  parseDeployment(): void;
62
63
  parseDeploymentNode(astNode: ast.DeploymentNode): import("../../ast").ParsedAstDeployment.Node;
@@ -55,6 +55,7 @@ export declare function ViewsParser<TBase extends WithPredicates & WithDeploymen
55
55
  parseFqnExpr(astNode: ast.FqnExpr): c4.FqnExpr;
56
56
  parseFqnRefExpr(astNode: ast.FqnRefExpr): c4.FqnExpr.NonWildcard;
57
57
  parseFqnExpressions(astNode: ast.FqnExpressions): c4.FqnExpr[];
58
+ parseRelationWhereExpr(astNode: ast.RelationPredicateWhereV2): c4.RelationExpr;
58
59
  parseRelationExpr(astNode: ast.RelationExpr): c4.RelationExpr;
59
60
  parseDeployment(): void;
60
61
  parseDeploymentNode(astNode: ast.DeploymentNode): import("../../ast").ParsedAstDeployment.Node;
@@ -3,7 +3,7 @@ import { type LikeC4LangiumDocument, ast } from '../ast';
3
3
  import type { LikeC4Services } from '../module';
4
4
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
5
5
  type Guarded<G> = G extends Guard<infer N> ? N : never;
6
- declare const isValidatableAstNode: (n: AstNode) => n is ast.DeployedInstance | ast.DeploymentNode | ast.DeploymentViewRulePredicate | ast.DeploymentViewRuleStyle | ast.ViewRuleAutoLayout | ast.DynamicViewGlobalPredicateRef | ast.DynamicViewIncludePredicate | ast.ViewRuleGlobalStyle | ast.ViewRuleStyle | ast.ElementDescedantsExpression | ast.ElementKindExpression | ast.ElementRef | ast.ElementTagExpression | ast.ExpandElementExpression | ast.WildcardExpression | ast.ElementPredicateWhere | ast.ElementPredicateWith | ast.ElementStringProperty | ast.ElementStyleProperty | ast.IconProperty | ast.LinkProperty | ast.MetadataBody | ast.FqnRefExpr | ast.DirectedRelationExpr | ast.InOutRelationExpr | ast.IncomingRelationExpr | ast.OutgoingRelationExpr | ast.Element | ast.ExtendElement | ast.DeploymentView | ast.DynamicView | ast.ElementView | ast.DirectedRelationExpression | ast.InOutRelationExpression | ast.IncomingRelationExpression | ast.OutgoingRelationExpression | ast.RelationPredicateWhere | ast.RelationPredicateWith | ast.RelationStringProperty | ast.ArrowProperty | ast.ColorProperty | ast.LineProperty | ast.MetadataAttribute | ast.NotationProperty | ast.NotesProperty | ast.SpecificationElementStringProperty | ast.SpecificationRelationshipStringProperty | ast.ViewStringProperty | ast.BorderProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewRuleGlobalPredicateRef | ast.ViewRuleGroup | ast.ExcludePredicate | ast.IncludePredicate | ast.SpecificationRelationshipKind | ast.GlobalStyle | ast.SpecificationColor | ast.NavigateToProperty | ast.DynamicViewStep | ast.Tags | ast.DeploymentRelation | ast.SpecificationDeploymentNodeKind | ast.DynamicViewParallelSteps | ast.GlobalDynamicPredicateGroup | ast.DynamicViewPredicateIterator | ast.Relation | ast.SpecificationElementKind | ast.GlobalPredicateGroup | ast.Globals | ast.GlobalStyleGroup | ast.SpecificationRule | ast.SpecificationTag;
6
+ declare const isValidatableAstNode: (n: AstNode) => n is ast.DeployedInstance | ast.DeploymentNode | ast.DeploymentViewRulePredicate | ast.DeploymentViewRuleStyle | ast.ViewRuleAutoLayout | ast.DynamicViewGlobalPredicateRef | ast.DynamicViewIncludePredicate | ast.ViewRuleGlobalStyle | ast.ViewRuleStyle | ast.ElementDescedantsExpression | ast.ElementKindExpression | ast.ElementRef | ast.ElementTagExpression | ast.ExpandElementExpression | ast.WildcardExpression | ast.ElementPredicateWhere | ast.ElementPredicateWith | ast.ElementStringProperty | ast.ElementStyleProperty | ast.IconProperty | ast.LinkProperty | ast.MetadataBody | ast.FqnRefExpr | ast.DirectedRelationExpr | ast.InOutRelationExpr | ast.IncomingRelationExpr | ast.OutgoingRelationExpr | ast.RelationPredicateWhereV2 | ast.Element | ast.ExtendElement | ast.DeploymentView | ast.DynamicView | ast.ElementView | ast.DirectedRelationExpression | ast.InOutRelationExpression | ast.IncomingRelationExpression | ast.OutgoingRelationExpression | ast.RelationPredicateWhere | ast.RelationPredicateWith | ast.RelationStringProperty | ast.ArrowProperty | ast.ColorProperty | ast.LineProperty | ast.MetadataAttribute | ast.NotationProperty | ast.NotesProperty | ast.SpecificationElementStringProperty | ast.SpecificationRelationshipStringProperty | ast.ViewStringProperty | ast.BorderProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewRuleGlobalPredicateRef | ast.ViewRuleGroup | ast.ExcludePredicate | ast.IncludePredicate | ast.SpecificationRelationshipKind | ast.GlobalStyle | ast.SpecificationColor | ast.NavigateToProperty | ast.DynamicViewStep | ast.Tags | ast.DeploymentRelation | ast.SpecificationDeploymentNodeKind | ast.DynamicViewParallelSteps | ast.GlobalDynamicPredicateGroup | ast.DynamicViewPredicateIterator | ast.Relation | ast.SpecificationElementKind | ast.GlobalPredicateGroup | ast.Globals | ast.GlobalStyleGroup | ast.SpecificationRule | ast.SpecificationTag;
7
7
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
8
8
  export declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
9
9
  isValid: (n: ValidatableAstNode) => boolean;
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.19.1",
4
+ "version": "1.20.0",
5
5
  "license": "MIT",
6
6
  "bugs": "https://github.com/likec4/likec4/issues",
7
7
  "homepage": "https://likec4.dev",
@@ -17,7 +17,7 @@
17
17
  ],
18
18
  "repository": {
19
19
  "type": "git",
20
- "url": "https://github.com/likec4/likec4.git",
20
+ "url": "git+https://github.com/likec4/likec4.git",
21
21
  "directory": "packages/language-server"
22
22
  },
23
23
  "type": "module",
@@ -82,9 +82,9 @@
82
82
  "test:watch": "vitest"
83
83
  },
84
84
  "dependencies": {
85
- "@likec4/core": "1.19.1",
86
- "@likec4/layouts": "1.19.1",
87
- "@likec4/log": "1.19.1",
85
+ "@likec4/core": "1.20.0",
86
+ "@likec4/layouts": "1.20.0",
87
+ "@likec4/log": "1.20.0",
88
88
  "@msgpack/msgpack": "^3.0.0-beta2",
89
89
  "@smithy/util-base64": "^3.0.0",
90
90
  "esm-env": "^1.2.1",
@@ -94,7 +94,7 @@
94
94
  "json5": "^2.2.3",
95
95
  "langium": "3.3.0",
96
96
  "p-debounce": "^4.0.0",
97
- "remeda": "^2.17.4",
97
+ "remeda": "^2.19.0",
98
98
  "strip-indent": "^4.0.0",
99
99
  "type-fest": "4.28.1",
100
100
  "ufo": "^1.5.4",
@@ -105,8 +105,8 @@
105
105
  "which": "^4.0.0"
106
106
  },
107
107
  "devDependencies": {
108
- "@likec4/icons": "1.19.1",
109
- "@likec4/tsconfig": "1.19.1",
108
+ "@likec4/icons": "1.20.0",
109
+ "@likec4/tsconfig": "1.20.0",
110
110
  "@types/node": "^20.17.7",
111
111
  "@types/which": "^3.0.4",
112
112
  "@vitest/coverage-v8": "^2.1.8",
@@ -116,9 +116,9 @@
116
116
  "npm-run-all2": "^7.0.1",
117
117
  "tsx": "~4.19.2",
118
118
  "turbo": "^2.3.3",
119
- "typescript": "^5.7.2",
120
- "unbuild": "^3.1.0",
119
+ "typescript": "^5.7.3",
120
+ "unbuild": "^3.2.0",
121
121
  "vitest": "^2.1.8"
122
122
  },
123
- "packageManager": "yarn@4.5.3"
123
+ "packageManager": "yarn@4.6.0"
124
124
  }