@likec4/language-server 1.1.1 → 1.2.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 (39) hide show
  1. package/contrib/likec4.monarch.ts +4 -4
  2. package/contrib/likec4.tmLanguage.json +1 -1
  3. package/dist/ast.d.ts +27 -11
  4. package/dist/ast.js +11 -7
  5. package/dist/generated/ast.d.ts +75 -19
  6. package/dist/generated/ast.js +96 -7
  7. package/dist/generated/grammar.js +1 -1
  8. package/dist/lsp/CodeLensProvider.js +5 -2
  9. package/dist/lsp/DocumentSymbolProvider.d.ts +1 -1
  10. package/dist/lsp/DocumentSymbolProvider.js +14 -9
  11. package/dist/lsp/SemanticTokenProvider.js +1 -1
  12. package/dist/model/model-builder.js +28 -15
  13. package/dist/model/model-locator.d.ts +2 -2
  14. package/dist/model/model-locator.js +12 -16
  15. package/dist/model/model-parser.d.ts +2 -0
  16. package/dist/model/model-parser.js +143 -33
  17. package/dist/model-change/ModelChanges.d.ts +2 -1
  18. package/dist/model-change/ModelChanges.js +26 -20
  19. package/dist/model-change/changeElementStyle.d.ts +8 -5
  20. package/dist/model-change/changeElementStyle.js +23 -23
  21. package/dist/model-change/changeViewLayout.d.ts +4 -4
  22. package/dist/model-change/changeViewLayout.js +4 -5
  23. package/dist/references/scope-computation.js +31 -28
  24. package/dist/shared/NodeKindProvider.js +4 -2
  25. package/dist/validation/dynamic-view-rule.d.ts +5 -0
  26. package/dist/validation/dynamic-view-rule.js +32 -0
  27. package/dist/validation/dynamic-view-step.d.ts +5 -0
  28. package/dist/validation/dynamic-view-step.js +33 -0
  29. package/dist/validation/index.js +5 -1
  30. package/dist/validation/view-predicates/expanded-element.js +1 -0
  31. package/dist/validation/view-predicates/outgoing.js +2 -2
  32. package/dist/validation/view.d.ts +1 -1
  33. package/dist/validation/view.js +1 -3
  34. package/dist/view-utils/assignNavigateTo.d.ts +1 -1
  35. package/dist/view-utils/assignNavigateTo.js +2 -1
  36. package/dist/view-utils/resolve-extended-views.d.ts +2 -2
  37. package/dist/view-utils/resolve-relative-paths.d.ts +2 -2
  38. package/dist/view-utils/resolve-relative-paths.js +2 -3
  39. package/package.json +6 -6
@@ -1,12 +1,12 @@
1
1
  // Monarch syntax highlighting for the likec4 language.
2
2
  export default {
3
3
  keywords: [
4
- 'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','border','browser','color','crow','cylinder','dashed','description','diamond','dotted','element','exclude','extend','extends','gray','green','head','icon','include','indigo','it','kind','line','link','mobile','model','muted','navigateTo','none','normal','odiamond','of','onormal','opacity','open','person','primary','queue','rectangle','red','relationship','secondary','shape','sky','slate','solid','specification','storage','style','tag','tail','technology','this','title','vee','view','views','with'
4
+ 'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','border','browser','color','crow','cylinder','dashed','description','diamond','dotted','dynamic','element','exclude','extend','extends','gray','green','head','icon','include','indigo','it','kind','line','link','mobile','model','muted','navigateTo','none','normal','odiamond','of','onormal','opacity','open','person','primary','queue','rectangle','red','relationship','secondary','shape','sky','slate','solid','specification','storage','style','tag','tail','technology','this','title','vee','view','views','with'
5
5
  ],
6
6
  operators: [
7
- '*','->','<->'
7
+ '*','->','<-','<->'
8
8
  ],
9
- symbols: /\*|->|-\[|<->|\]->|\{|\}/,
9
+ symbols: /\*|->|-\[|<-|<->|\]->|\{|\}/,
10
10
 
11
11
  tokenizer: {
12
12
  initial: [
@@ -23,7 +23,7 @@ export default {
23
23
  { regex: /,/, action: {"token":"Comma"} },
24
24
  { regex: /\b\d+%/, action: {"token":"Percent"} },
25
25
  { regex: /"[^"]*"|'[^']*'/, action: {"token":"string"} },
26
- { regex: /\b(_+[a-zA-Z]|[a-zA-Z])[\w_-]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"IdTerminal"} }} },
26
+ { regex: /\b[_]*[a-zA-Z][_-\w]*/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"IdTerminal"} }} },
27
27
  { include: '@whitespace' },
28
28
  { regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
29
29
  ],
@@ -12,7 +12,7 @@
12
12
  },
13
13
  {
14
14
  "name": "keyword.control.likec4",
15
- "match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|autoLayout|blue|border|browser|color|crow|cylinder|dashed|description|diamond|dotted|element|exclude|extend|extends|gray|green|head|icon|include|indigo|it|kind|line|link|mobile|model|muted|navigateTo|none|normal|odiamond|of|onormal|opacity|open|person|primary|queue|rectangle|red|relationship|secondary|shape|sky|slate|solid|specification|storage|style|tag|tail|technology|this|title|vee|view|views|with)\\b"
15
+ "match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|autoLayout|blue|border|browser|color|crow|cylinder|dashed|description|diamond|dotted|dynamic|element|exclude|extend|extends|gray|green|head|icon|include|indigo|it|kind|line|link|mobile|model|muted|navigateTo|none|normal|odiamond|of|onormal|opacity|open|person|primary|queue|rectangle|red|relationship|secondary|shape|sky|slate|solid|specification|storage|style|tag|tail|technology|this|title|vee|view|views|with)\\b"
16
16
  },
17
17
  {
18
18
  "name": "string.quoted.double.likec4",
package/dist/ast.d.ts CHANGED
@@ -14,6 +14,9 @@ declare module './generated/ast' {
14
14
  interface ElementView {
15
15
  [idattr]?: c4.ViewID | undefined;
16
16
  }
17
+ interface DynamicView {
18
+ [idattr]?: c4.ViewID | undefined;
19
+ }
17
20
  }
18
21
  type ParsedElementStyle = {
19
22
  shape?: c4.ElementShape;
@@ -57,19 +60,32 @@ export interface ParsedAstRelation {
57
60
  links?: c4.NonEmptyArray<string>;
58
61
  }
59
62
  export interface ParsedAstElementView {
63
+ __: 'element';
60
64
  id: c4.ViewID;
61
65
  viewOf?: c4.Fqn;
62
66
  extends?: c4.ViewID;
63
67
  astPath: string;
64
- title?: string;
65
- description?: string;
66
- tags?: c4.NonEmptyArray<c4.Tag>;
67
- links?: c4.NonEmptyArray<string>;
68
+ title: string | null;
69
+ description: string | null;
70
+ tags: c4.NonEmptyArray<c4.Tag> | null;
71
+ links: c4.NonEmptyArray<string> | null;
68
72
  rules: c4.ViewRule[];
69
73
  }
70
- export declare const ElementViewOps: {
71
- writeId(node: ast.ElementView, id: c4.ViewID): ast.ElementView;
72
- readId(node: ast.ElementView): c4.ViewID | undefined;
74
+ export interface ParsedAstDynamicView {
75
+ __: 'dynamic';
76
+ id: c4.ViewID;
77
+ astPath: string;
78
+ title: string | null;
79
+ description: string | null;
80
+ tags: c4.NonEmptyArray<c4.Tag> | null;
81
+ links: c4.NonEmptyArray<string> | null;
82
+ steps: c4.DynamicViewStep[];
83
+ rules: Array<c4.DynamicViewRule>;
84
+ }
85
+ export type ParsedAstView = ParsedAstElementView | ParsedAstDynamicView;
86
+ export declare const ViewOps: {
87
+ writeId<T extends ast.LikeC4View>(node: T, id: c4.ViewID): T;
88
+ readId(node: ast.LikeC4View): c4.ViewID | undefined;
73
89
  };
74
90
  export declare const ElementOps: {
75
91
  writeId(node: ast.Element, id: c4.Fqn | null): ast.Element;
@@ -87,7 +103,7 @@ export interface LikeC4DocumentProps {
87
103
  c4Specification?: ParsedAstSpecification;
88
104
  c4Elements?: ParsedAstElement[];
89
105
  c4Relations?: ParsedAstRelation[];
90
- c4Views?: ParsedAstElementView[];
106
+ c4Views?: ParsedAstView[];
91
107
  c4fqns?: MultiMap<c4.Fqn, DocFqnIndexEntry>;
92
108
  }
93
109
  export interface LikeC4LangiumDocument extends Omit<LangiumDocument<LikeC4Grammar>, 'diagnostics'>, LikeC4DocumentProps {
@@ -102,14 +118,14 @@ export declare function isLikeC4LangiumDocument(doc: LangiumDocument): doc is Li
102
118
  export declare function isParsedLikeC4LangiumDocument(doc: LangiumDocument): doc is ParsedLikeC4LangiumDocument;
103
119
  type Guard<N extends AstNode> = (n: AstNode) => n is N;
104
120
  type Guarded<G> = G extends Guard<infer N> ? N : never;
105
- declare const isValidatableAstNode: (n: AstNode) => n is ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ViewStringProperty | ast.ViewRuleAutoLayout | ast.ExcludePredicate | ast.IncludePredicate | ast.ViewRuleStyle | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.CustomElementExprBody | ast.SpecificationElementKind | ast.ElementViewBody | ast.ElementView | ast.ModelViews | ast.Tags | ast.SpecificationTag;
121
+ declare const isValidatableAstNode: (n: AstNode) => n is ast.DynamicViewRulePredicate | ast.ViewRuleAutoLayout | ast.ViewRuleStyle | ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.DynamicView | ast.ElementView | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ColorProperty | ast.BorderProperty | ast.IconProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewStringProperty | ast.ExcludePredicate | ast.IncludePredicate | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.CustomElementExprBody | ast.DynamicViewBody | ast.ElementViewBody | ast.ModelViews | ast.SpecificationElementKind | ast.DynamicViewStep | ast.Tags | ast.SpecificationTag;
106
122
  type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
107
123
  export declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
108
124
  isValid: (n: ValidatableAstNode) => boolean;
109
- invalidNodes: WeakSet<ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ViewStringProperty | ast.ViewRuleAutoLayout | ast.ExcludePredicate | ast.IncludePredicate | ast.ViewRuleStyle | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.CustomElementExprBody | ast.SpecificationElementKind | ast.ElementViewBody | ast.ElementView | ast.ModelViews | ast.Tags | ast.SpecificationTag>;
125
+ invalidNodes: WeakSet<ast.DynamicViewRulePredicate | ast.ViewRuleAutoLayout | ast.ViewRuleStyle | ast.DescedantsExpr | ast.ElementKindExpr | ast.ElementRef | ast.ElementTagExpr | ast.ExpandElementExpr | ast.WildcardExpr | ast.ElementStringProperty | ast.LinkProperty | ast.StyleProperties | ast.DynamicView | ast.ElementView | ast.ExplicitRelation | ast.ImplicitRelation | ast.RelationStringProperty | ast.RelationStyleProperty | ast.ColorProperty | ast.BorderProperty | ast.IconProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewStringProperty | ast.ExcludePredicate | ast.IncludePredicate | ast.CustomElementExpr | ast.InOutExpr | ast.IncomingExpr | ast.OutgoingExpr | ast.RelationExpr | ast.SpecificationRelationshipKind | ast.RelationBody | ast.ElementBody | ast.ExtendElementBody | ast.Model | ast.Element | ast.ExtendElement | ast.SpecificationRule | ast.CustomElementExprBody | ast.DynamicViewBody | ast.ElementViewBody | ast.ModelViews | ast.SpecificationElementKind | ast.DynamicViewStep | ast.Tags | ast.SpecificationTag>;
110
126
  };
111
127
  export type ChecksFromDiagnostics = ReturnType<typeof checksFromDiagnostics>;
112
- export declare function streamModel(doc: LikeC4LangiumDocument): Generator<ast.Relation | ast.Element, void, unknown>;
128
+ export declare function streamModel(doc: LikeC4LangiumDocument, isValid: ChecksFromDiagnostics['isValid']): Generator<ast.Relation | ast.Element, void, unknown>;
113
129
  export declare function resolveRelationPoints(node: ast.Relation): {
114
130
  source: ast.Element;
115
131
  target: ast.Element;
package/dist/ast.js CHANGED
@@ -13,7 +13,7 @@ import * as ast from "./generated/ast.js";
13
13
  import { LikeC4LanguageMetaData } from "./generated/module.js";
14
14
  export { ast };
15
15
  const idattr = Symbol.for("idattr");
16
- export const ElementViewOps = {
16
+ export const ViewOps = {
17
17
  writeId(node, id) {
18
18
  node[idattr] = id;
19
19
  return node;
@@ -62,11 +62,16 @@ function validatableAstNodeGuards(predicates) {
62
62
  const isValidatableAstNode = validatableAstNodeGuards([
63
63
  ast.isCustomElementExprBody,
64
64
  ast.isViewRulePredicateExpr,
65
+ ast.isDynamicViewRulePredicate,
66
+ ast.isViewProperty,
67
+ ast.isStyleProperty,
65
68
  ast.isTags,
66
69
  ast.isViewRule,
67
- ast.isViewProperty,
70
+ ast.isDynamicViewRule,
71
+ ast.isDynamicViewStep,
68
72
  ast.isElementViewBody,
69
- ast.isElementView,
73
+ ast.isDynamicViewBody,
74
+ ast.isLikeC4View,
70
75
  ast.isRelationProperty,
71
76
  ast.isRelationBody,
72
77
  ast.isRelation,
@@ -79,8 +84,8 @@ const isValidatableAstNode = validatableAstNodeGuards([
79
84
  ast.isSpecificationRelationshipKind,
80
85
  ast.isSpecificationTag,
81
86
  ast.isSpecificationRule,
82
- ast.isModel,
83
- ast.isModelViews
87
+ ast.isModelViews,
88
+ ast.isModel
84
89
  ]);
85
90
  export function checksFromDiagnostics(doc) {
86
91
  const errors = doc.diagnostics?.filter((d) => d.severity === DiagnosticSeverity.Error) ?? [];
@@ -95,8 +100,7 @@ export function checksFromDiagnostics(doc) {
95
100
  invalidNodes
96
101
  };
97
102
  }
98
- export function* streamModel(doc) {
99
- const { isValid } = checksFromDiagnostics(doc);
103
+ export function* streamModel(doc, isValid) {
100
104
  const traverseStack = doc.parseResult.value.models.flatMap((m) => isValid(m) ? m.elements : []);
101
105
  const relations = [];
102
106
  let el;
@@ -27,6 +27,9 @@ export type ArrowType = 'crow' | 'diamond' | 'none' | 'normal' | 'odiamond' | 'o
27
27
  export declare function isArrowType(item: unknown): item is ArrowType;
28
28
  export type BorderStyleValue = 'none' | LineOptions;
29
29
  export declare function isBorderStyleValue(item: unknown): item is BorderStyleValue;
30
+ export type DynamicViewRule = DynamicViewRulePredicate | ViewRuleAutoLayout | ViewRuleStyle;
31
+ export declare const DynamicViewRule = "DynamicViewRule";
32
+ export declare function isDynamicViewRule(item: unknown): item is DynamicViewRule;
30
33
  export type ElementExpr = DescedantsExpr | ElementKindExpr | ElementRef | ElementTagExpr | ExpandElementExpr | WildcardExpr;
31
34
  export declare const ElementExpr = "ElementExpr";
32
35
  export declare function isElementExpr(item: unknown): item is ElementExpr;
@@ -37,6 +40,9 @@ export type ElementShape = 'browser' | 'cylinder' | 'mobile' | 'person' | 'queue
37
40
  export declare function isElementShape(item: unknown): item is ElementShape;
38
41
  export type Id = 'element' | 'model' | ArrowType | ElementShape | LineOptions | ThemeColor | string;
39
42
  export declare function isId(item: unknown): item is Id;
43
+ export type LikeC4View = DynamicView | ElementView;
44
+ export declare const LikeC4View = "LikeC4View";
45
+ export declare function isLikeC4View(item: unknown): item is LikeC4View;
40
46
  export type LineOptions = 'dashed' | 'dotted' | 'solid';
41
47
  export declare function isLineOptions(item: unknown): item is LineOptions;
42
48
  export type Relation = ExplicitRelation | ImplicitRelation;
@@ -96,7 +102,7 @@ export interface ColorProperty extends AstNode {
96
102
  export declare const ColorProperty = "ColorProperty";
97
103
  export declare function isColorProperty(item: unknown): item is ColorProperty;
98
104
  export interface CustomElementExpr extends AstNode {
99
- readonly $container: ExcludePredicate | IncludePredicate;
105
+ readonly $container: DynamicViewRulePredicate | ExcludePredicate | IncludePredicate;
100
106
  readonly $type: 'CustomElementExpr';
101
107
  body: CustomElementExprBody;
102
108
  target: ElementExpr;
@@ -111,12 +117,48 @@ export interface CustomElementExprBody extends AstNode {
111
117
  export declare const CustomElementExprBody = "CustomElementExprBody";
112
118
  export declare function isCustomElementExprBody(item: unknown): item is CustomElementExprBody;
113
119
  export interface DescedantsExpr extends AstNode {
114
- readonly $container: CustomElementExpr | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
120
+ readonly $container: CustomElementExpr | DynamicViewRulePredicate | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
115
121
  readonly $type: 'DescedantsExpr';
116
122
  parent: ElementRef;
117
123
  }
118
124
  export declare const DescedantsExpr = "DescedantsExpr";
119
125
  export declare function isDescedantsExpr(item: unknown): item is DescedantsExpr;
126
+ export interface DynamicView extends AstNode {
127
+ readonly $container: ModelViews;
128
+ readonly $type: 'DynamicView';
129
+ body: DynamicViewBody;
130
+ name: Id;
131
+ }
132
+ export declare const DynamicView = "DynamicView";
133
+ export declare function isDynamicView(item: unknown): item is DynamicView;
134
+ export interface DynamicViewBody extends AstNode {
135
+ readonly $container: DynamicView;
136
+ readonly $type: 'DynamicViewBody';
137
+ props: Array<ViewProperty>;
138
+ rules: Array<DynamicViewRule>;
139
+ steps: Array<DynamicViewStep>;
140
+ tags?: Tags;
141
+ }
142
+ export declare const DynamicViewBody = "DynamicViewBody";
143
+ export declare function isDynamicViewBody(item: unknown): item is DynamicViewBody;
144
+ export interface DynamicViewRulePredicate extends AstNode {
145
+ readonly $container: DynamicViewBody;
146
+ readonly $type: 'DynamicViewRulePredicate';
147
+ expressions: Array<ViewRulePredicateExpr>;
148
+ }
149
+ export declare const DynamicViewRulePredicate = "DynamicViewRulePredicate";
150
+ export declare function isDynamicViewRulePredicate(item: unknown): item is DynamicViewRulePredicate;
151
+ export interface DynamicViewStep extends AstNode {
152
+ readonly $container: DynamicViewBody;
153
+ readonly $type: 'DynamicViewStep';
154
+ isBackward: boolean;
155
+ kind?: Reference<RelationshipKind>;
156
+ source: ElementRef;
157
+ target: ElementRef;
158
+ title?: string;
159
+ }
160
+ export declare const DynamicViewStep = "DynamicViewStep";
161
+ export declare function isDynamicViewStep(item: unknown): item is DynamicViewStep;
120
162
  export interface Element extends AstNode {
121
163
  readonly $container: ElementBody | ExtendElementBody | Model;
122
164
  readonly $type: 'Element';
@@ -144,7 +186,7 @@ export interface ElementKind extends AstNode {
144
186
  export declare const ElementKind = "ElementKind";
145
187
  export declare function isElementKind(item: unknown): item is ElementKind;
146
188
  export interface ElementKindExpr extends AstNode {
147
- readonly $container: CustomElementExpr | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
189
+ readonly $container: CustomElementExpr | DynamicViewRulePredicate | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
148
190
  readonly $type: 'ElementKindExpr';
149
191
  isEqual: boolean;
150
192
  kind: Reference<ElementKind>;
@@ -152,7 +194,7 @@ export interface ElementKindExpr extends AstNode {
152
194
  export declare const ElementKindExpr = "ElementKindExpr";
153
195
  export declare function isElementKindExpr(item: unknown): item is ElementKindExpr;
154
196
  export interface ElementRef extends AstNode {
155
- readonly $container: CustomElementExpr | DescedantsExpr | ElementRef | ElementView | ExcludePredicate | ExpandElementExpr | ExplicitRelation | ImplicitRelation | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
197
+ readonly $container: CustomElementExpr | DescedantsExpr | DynamicViewRulePredicate | DynamicViewStep | ElementRef | ElementView | ExcludePredicate | ExpandElementExpr | ExplicitRelation | ImplicitRelation | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
156
198
  readonly $type: 'ElementRef';
157
199
  el: Reference<Element>;
158
200
  parent?: ElementRef;
@@ -168,7 +210,7 @@ export interface ElementStringProperty extends AstNode {
168
210
  export declare const ElementStringProperty = "ElementStringProperty";
169
211
  export declare function isElementStringProperty(item: unknown): item is ElementStringProperty;
170
212
  export interface ElementTagExpr extends AstNode {
171
- readonly $container: CustomElementExpr | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
213
+ readonly $container: CustomElementExpr | DynamicViewRulePredicate | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
172
214
  readonly $type: 'ElementTagExpr';
173
215
  isEqual: boolean;
174
216
  tag: Reference<Tag>;
@@ -195,7 +237,7 @@ export interface ElementViewBody extends AstNode {
195
237
  export declare const ElementViewBody = "ElementViewBody";
196
238
  export declare function isElementViewBody(item: unknown): item is ElementViewBody;
197
239
  export interface ElementViewRef extends AstNode {
198
- readonly $container: ElementView | NavigateToProperty;
240
+ readonly $container: ElementView;
199
241
  readonly $type: 'ElementViewRef';
200
242
  view: Reference<ElementView>;
201
243
  }
@@ -209,7 +251,7 @@ export interface ExcludePredicate extends AstNode {
209
251
  export declare const ExcludePredicate = "ExcludePredicate";
210
252
  export declare function isExcludePredicate(item: unknown): item is ExcludePredicate;
211
253
  export interface ExpandElementExpr extends AstNode {
212
- readonly $container: CustomElementExpr | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
254
+ readonly $container: CustomElementExpr | DynamicViewRulePredicate | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
213
255
  readonly $type: 'ExpandElementExpr';
214
256
  parent: ElementRef;
215
257
  }
@@ -277,14 +319,14 @@ export interface IncludePredicate extends AstNode {
277
319
  export declare const IncludePredicate = "IncludePredicate";
278
320
  export declare function isIncludePredicate(item: unknown): item is IncludePredicate;
279
321
  export interface IncomingExpr extends AstNode {
280
- readonly $container: ExcludePredicate | InOutExpr | IncludePredicate;
322
+ readonly $container: DynamicViewRulePredicate | ExcludePredicate | InOutExpr | IncludePredicate;
281
323
  readonly $type: 'IncomingExpr';
282
324
  to: ElementExpr;
283
325
  }
284
326
  export declare const IncomingExpr = "IncomingExpr";
285
327
  export declare function isIncomingExpr(item: unknown): item is IncomingExpr;
286
328
  export interface InOutExpr extends AstNode {
287
- readonly $container: ExcludePredicate | IncludePredicate;
329
+ readonly $container: DynamicViewRulePredicate | ExcludePredicate | IncludePredicate;
288
330
  readonly $type: 'InOutExpr';
289
331
  inout: IncomingExpr;
290
332
  }
@@ -307,7 +349,7 @@ export interface LineProperty extends AstNode {
307
349
  export declare const LineProperty = "LineProperty";
308
350
  export declare function isLineProperty(item: unknown): item is LineProperty;
309
351
  export interface LinkProperty extends AstNode {
310
- readonly $container: ElementBody | ElementViewBody | RelationBody;
352
+ readonly $container: DynamicViewBody | ElementBody | ElementViewBody | RelationBody;
311
353
  readonly $type: 'LinkProperty';
312
354
  key: 'link';
313
355
  value: Uri;
@@ -326,14 +368,14 @@ export interface ModelViews extends AstNode {
326
368
  readonly $container: LikeC4Grammar;
327
369
  readonly $type: 'ModelViews';
328
370
  name: 'views';
329
- views: Array<ElementView>;
371
+ views: Array<DynamicView | ElementView>;
330
372
  }
331
373
  export declare const ModelViews = "ModelViews";
332
374
  export declare function isModelViews(item: unknown): item is ModelViews;
333
375
  export interface NavigateToProperty extends AstNode {
334
376
  readonly $container: CustomElementExprBody;
335
377
  readonly $type: 'NavigateToProperty';
336
- value: ElementViewRef;
378
+ value: ViewRef;
337
379
  }
338
380
  export declare const NavigateToProperty = "NavigateToProperty";
339
381
  export declare function isNavigateToProperty(item: unknown): item is NavigateToProperty;
@@ -346,7 +388,7 @@ export interface OpacityProperty extends AstNode {
346
388
  export declare const OpacityProperty = "OpacityProperty";
347
389
  export declare function isOpacityProperty(item: unknown): item is OpacityProperty;
348
390
  export interface OutgoingExpr extends AstNode {
349
- readonly $container: ExcludePredicate | IncludePredicate;
391
+ readonly $container: DynamicViewRulePredicate | ExcludePredicate | IncludePredicate;
350
392
  readonly $type: 'OutgoingExpr';
351
393
  from: ElementExpr;
352
394
  }
@@ -361,7 +403,7 @@ export interface RelationBody extends AstNode {
361
403
  export declare const RelationBody = "RelationBody";
362
404
  export declare function isRelationBody(item: unknown): item is RelationBody;
363
405
  export interface RelationExpr extends AstNode {
364
- readonly $container: ExcludePredicate | IncludePredicate;
406
+ readonly $container: DynamicViewRulePredicate | ExcludePredicate | IncludePredicate;
365
407
  readonly $type: 'RelationExpr';
366
408
  isBidirectional: boolean;
367
409
  source: ElementExpr;
@@ -449,21 +491,28 @@ export interface Tag extends AstNode {
449
491
  export declare const Tag = "Tag";
450
492
  export declare function isTag(item: unknown): item is Tag;
451
493
  export interface Tags extends AstNode {
452
- readonly $container: ElementBody | ElementViewBody | ExplicitRelation | ImplicitRelation | RelationBody;
494
+ readonly $container: DynamicViewBody | ElementBody | ElementViewBody | ExplicitRelation | ImplicitRelation | RelationBody;
453
495
  readonly $type: 'Tags';
454
496
  value: Array<Reference<Tag>>;
455
497
  }
456
498
  export declare const Tags = "Tags";
457
499
  export declare function isTags(item: unknown): item is Tags;
500
+ export interface ViewRef extends AstNode {
501
+ readonly $container: NavigateToProperty;
502
+ readonly $type: 'ViewRef';
503
+ view: Reference<LikeC4View>;
504
+ }
505
+ export declare const ViewRef = "ViewRef";
506
+ export declare function isViewRef(item: unknown): item is ViewRef;
458
507
  export interface ViewRuleAutoLayout extends AstNode {
459
- readonly $container: ElementViewBody;
508
+ readonly $container: DynamicViewBody | ElementViewBody;
460
509
  readonly $type: 'ViewRuleAutoLayout';
461
510
  direction: ViewLayoutDirection;
462
511
  }
463
512
  export declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
464
513
  export declare function isViewRuleAutoLayout(item: unknown): item is ViewRuleAutoLayout;
465
514
  export interface ViewRuleStyle extends AstNode {
466
- readonly $container: ElementViewBody;
515
+ readonly $container: DynamicViewBody | ElementViewBody;
467
516
  readonly $type: 'ViewRuleStyle';
468
517
  styleprops: Array<StyleProperty>;
469
518
  targets: Array<ElementExpr>;
@@ -471,7 +520,7 @@ export interface ViewRuleStyle extends AstNode {
471
520
  export declare const ViewRuleStyle = "ViewRuleStyle";
472
521
  export declare function isViewRuleStyle(item: unknown): item is ViewRuleStyle;
473
522
  export interface ViewStringProperty extends AstNode {
474
- readonly $container: ElementViewBody;
523
+ readonly $container: DynamicViewBody | ElementViewBody;
475
524
  readonly $type: 'ViewStringProperty';
476
525
  key: 'description' | 'title';
477
526
  value: string;
@@ -479,7 +528,7 @@ export interface ViewStringProperty extends AstNode {
479
528
  export declare const ViewStringProperty = "ViewStringProperty";
480
529
  export declare function isViewStringProperty(item: unknown): item is ViewStringProperty;
481
530
  export interface WildcardExpr extends AstNode {
482
- readonly $container: CustomElementExpr | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
531
+ readonly $container: CustomElementExpr | DynamicViewRulePredicate | ExcludePredicate | IncludePredicate | IncomingExpr | OutgoingExpr | RelationExpr | ViewRuleStyle;
483
532
  readonly $type: 'WildcardExpr';
484
533
  isWildcard: boolean;
485
534
  }
@@ -492,6 +541,11 @@ export type LikeC4AstType = {
492
541
  CustomElementExpr: CustomElementExpr;
493
542
  CustomElementExprBody: CustomElementExprBody;
494
543
  DescedantsExpr: DescedantsExpr;
544
+ DynamicView: DynamicView;
545
+ DynamicViewBody: DynamicViewBody;
546
+ DynamicViewRule: DynamicViewRule;
547
+ DynamicViewRulePredicate: DynamicViewRulePredicate;
548
+ DynamicViewStep: DynamicViewStep;
495
549
  Element: Element;
496
550
  ElementBody: ElementBody;
497
551
  ElementExpr: ElementExpr;
@@ -516,6 +570,7 @@ export type LikeC4AstType = {
516
570
  IncludePredicate: IncludePredicate;
517
571
  IncomingExpr: IncomingExpr;
518
572
  LikeC4Grammar: LikeC4Grammar;
573
+ LikeC4View: LikeC4View;
519
574
  LineProperty: LineProperty;
520
575
  LinkProperty: LinkProperty;
521
576
  Model: Model;
@@ -541,6 +596,7 @@ export type LikeC4AstType = {
541
596
  Tag: Tag;
542
597
  Tags: Tags;
543
598
  ViewProperty: ViewProperty;
599
+ ViewRef: ViewRef;
544
600
  ViewRule: ViewRule;
545
601
  ViewRuleAutoLayout: ViewRuleAutoLayout;
546
602
  ViewRulePredicate: ViewRulePredicate;
@@ -16,7 +16,7 @@ export const LikeC4Terminals = {
16
16
  Comma: /,/,
17
17
  Percent: /\b\d+%/,
18
18
  String: /"[^"]*"|'[^']*'/,
19
- IdTerminal: /\b(_+[a-zA-Z]|[a-zA-Z])[\w_-]*/
19
+ IdTerminal: /\b[_]*[a-zA-Z][_-\w]*/
20
20
  };
21
21
  export function isArrowType(item) {
22
22
  return item === "none" || item === "normal" || item === "onormal" || item === "diamond" || item === "odiamond" || item === "crow" || item === "open" || item === "vee";
@@ -24,6 +24,10 @@ export function isArrowType(item) {
24
24
  export function isBorderStyleValue(item) {
25
25
  return isLineOptions(item) || item === "none";
26
26
  }
27
+ export const DynamicViewRule = "DynamicViewRule";
28
+ export function isDynamicViewRule(item) {
29
+ return reflection.isInstance(item, DynamicViewRule);
30
+ }
27
31
  export const ElementExpr = "ElementExpr";
28
32
  export function isElementExpr(item) {
29
33
  return reflection.isInstance(item, ElementExpr);
@@ -36,7 +40,11 @@ export function isElementShape(item) {
36
40
  return item === "rectangle" || item === "person" || item === "browser" || item === "mobile" || item === "cylinder" || item === "storage" || item === "queue";
37
41
  }
38
42
  export function isId(item) {
39
- return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" && /\b(_+[a-zA-Z]|[a-zA-Z])[\w_-]*/.test(item);
43
+ return isElementShape(item) || isThemeColor(item) || isArrowType(item) || isLineOptions(item) || item === "element" || item === "model" || typeof item === "string" && /\b[_]*[a-zA-Z][_-\w]*/.test(item);
44
+ }
45
+ export const LikeC4View = "LikeC4View";
46
+ export function isLikeC4View(item) {
47
+ return reflection.isInstance(item, LikeC4View);
40
48
  }
41
49
  export function isLineOptions(item) {
42
50
  return item === "solid" || item === "dashed" || item === "dotted";
@@ -109,6 +117,22 @@ export const DescedantsExpr = "DescedantsExpr";
109
117
  export function isDescedantsExpr(item) {
110
118
  return reflection.isInstance(item, DescedantsExpr);
111
119
  }
120
+ export const DynamicView = "DynamicView";
121
+ export function isDynamicView(item) {
122
+ return reflection.isInstance(item, DynamicView);
123
+ }
124
+ export const DynamicViewBody = "DynamicViewBody";
125
+ export function isDynamicViewBody(item) {
126
+ return reflection.isInstance(item, DynamicViewBody);
127
+ }
128
+ export const DynamicViewRulePredicate = "DynamicViewRulePredicate";
129
+ export function isDynamicViewRulePredicate(item) {
130
+ return reflection.isInstance(item, DynamicViewRulePredicate);
131
+ }
132
+ export const DynamicViewStep = "DynamicViewStep";
133
+ export function isDynamicViewStep(item) {
134
+ return reflection.isInstance(item, DynamicViewStep);
135
+ }
112
136
  export const Element = "Element";
113
137
  export function isElement(item) {
114
138
  return reflection.isInstance(item, Element);
@@ -277,6 +301,10 @@ export const Tags = "Tags";
277
301
  export function isTags(item) {
278
302
  return reflection.isInstance(item, Tags);
279
303
  }
304
+ export const ViewRef = "ViewRef";
305
+ export function isViewRef(item) {
306
+ return reflection.isInstance(item, ViewRef);
307
+ }
280
308
  export const ViewRuleAutoLayout = "ViewRuleAutoLayout";
281
309
  export function isViewRuleAutoLayout(item) {
282
310
  return reflection.isInstance(item, ViewRuleAutoLayout);
@@ -295,7 +323,7 @@ export function isWildcardExpr(item) {
295
323
  }
296
324
  export class LikeC4AstReflection extends AbstractAstReflection {
297
325
  getAllTypes() {
298
- return ["ArrowProperty", "BorderProperty", "ColorProperty", "CustomElementExpr", "CustomElementExprBody", "DescedantsExpr", "Element", "ElementBody", "ElementExpr", "ElementKind", "ElementKindExpr", "ElementProperty", "ElementRef", "ElementStringProperty", "ElementTagExpr", "ElementView", "ElementViewBody", "ElementViewRef", "ExcludePredicate", "ExpandElementExpr", "ExplicitRelation", "ExtendElement", "ExtendElementBody", "FqnElementRef", "IconProperty", "ImplicitRelation", "InOutExpr", "IncludePredicate", "IncomingExpr", "LikeC4Grammar", "LineProperty", "LinkProperty", "Model", "ModelViews", "NavigateToProperty", "OpacityProperty", "OutgoingExpr", "Relation", "RelationBody", "RelationExpr", "RelationProperty", "RelationStringProperty", "RelationStyleProperty", "RelationshipKind", "RelationshipStyleProperty", "ShapeProperty", "SpecificationElementKind", "SpecificationRelationshipKind", "SpecificationRule", "SpecificationTag", "StyleProperties", "StyleProperty", "Tag", "Tags", "ViewProperty", "ViewRule", "ViewRuleAutoLayout", "ViewRulePredicate", "ViewRulePredicateExpr", "ViewRuleStyle", "ViewStringProperty", "WildcardExpr"];
326
+ return ["ArrowProperty", "BorderProperty", "ColorProperty", "CustomElementExpr", "CustomElementExprBody", "DescedantsExpr", "DynamicView", "DynamicViewBody", "DynamicViewRule", "DynamicViewRulePredicate", "DynamicViewStep", "Element", "ElementBody", "ElementExpr", "ElementKind", "ElementKindExpr", "ElementProperty", "ElementRef", "ElementStringProperty", "ElementTagExpr", "ElementView", "ElementViewBody", "ElementViewRef", "ExcludePredicate", "ExpandElementExpr", "ExplicitRelation", "ExtendElement", "ExtendElementBody", "FqnElementRef", "IconProperty", "ImplicitRelation", "InOutExpr", "IncludePredicate", "IncomingExpr", "LikeC4Grammar", "LikeC4View", "LineProperty", "LinkProperty", "Model", "ModelViews", "NavigateToProperty", "OpacityProperty", "OutgoingExpr", "Relation", "RelationBody", "RelationExpr", "RelationProperty", "RelationStringProperty", "RelationStyleProperty", "RelationshipKind", "RelationshipStyleProperty", "ShapeProperty", "SpecificationElementKind", "SpecificationRelationshipKind", "SpecificationRule", "SpecificationTag", "StyleProperties", "StyleProperty", "Tag", "Tags", "ViewProperty", "ViewRef", "ViewRule", "ViewRuleAutoLayout", "ViewRulePredicate", "ViewRulePredicateExpr", "ViewRuleStyle", "ViewStringProperty", "WildcardExpr"];
299
327
  }
300
328
  computeIsSubtype(subtype, supertype) {
301
329
  switch (subtype) {
@@ -328,6 +356,13 @@ export class LikeC4AstReflection extends AbstractAstReflection {
328
356
  case WildcardExpr: {
329
357
  return this.isSubtype(ElementExpr, supertype);
330
358
  }
359
+ case DynamicView:
360
+ case ElementView: {
361
+ return this.isSubtype(LikeC4View, supertype);
362
+ }
363
+ case DynamicViewRulePredicate: {
364
+ return this.isSubtype(DynamicViewRule, supertype);
365
+ }
331
366
  case ElementStringProperty:
332
367
  case StyleProperties: {
333
368
  return this.isSubtype(ElementProperty, supertype);
@@ -348,8 +383,10 @@ export class LikeC4AstReflection extends AbstractAstReflection {
348
383
  return this.isSubtype(RelationProperty, supertype);
349
384
  }
350
385
  case ViewRuleAutoLayout:
351
- case ViewRulePredicate:
352
386
  case ViewRuleStyle: {
387
+ return this.isSubtype(DynamicViewRule, supertype) || this.isSubtype(ViewRule, supertype);
388
+ }
389
+ case ViewRulePredicate: {
353
390
  return this.isSubtype(ViewRule, supertype);
354
391
  }
355
392
  case ViewStringProperty: {
@@ -363,6 +400,11 @@ export class LikeC4AstReflection extends AbstractAstReflection {
363
400
  getReferenceType(refInfo) {
364
401
  const referenceId = `${refInfo.container.$type}:${refInfo.property}`;
365
402
  switch (referenceId) {
403
+ case "DynamicViewStep:kind":
404
+ case "ExplicitRelation:kind":
405
+ case "ImplicitRelation:kind": {
406
+ return RelationshipKind;
407
+ }
366
408
  case "Element:kind":
367
409
  case "ElementKindExpr:kind": {
368
410
  return ElementKind;
@@ -378,9 +420,8 @@ export class LikeC4AstReflection extends AbstractAstReflection {
378
420
  case "ElementViewRef:view": {
379
421
  return ElementView;
380
422
  }
381
- case "ExplicitRelation:kind":
382
- case "ImplicitRelation:kind": {
383
- return RelationshipKind;
423
+ case "ViewRef:view": {
424
+ return LikeC4View;
384
425
  }
385
426
  default: {
386
427
  throw new Error(`${referenceId} is not a valid reference id.`);
@@ -441,6 +482,46 @@ export class LikeC4AstReflection extends AbstractAstReflection {
441
482
  ]
442
483
  };
443
484
  }
485
+ case "DynamicView": {
486
+ return {
487
+ name: "DynamicView",
488
+ properties: [
489
+ { name: "body" },
490
+ { name: "name" }
491
+ ]
492
+ };
493
+ }
494
+ case "DynamicViewBody": {
495
+ return {
496
+ name: "DynamicViewBody",
497
+ properties: [
498
+ { name: "props", defaultValue: [] },
499
+ { name: "rules", defaultValue: [] },
500
+ { name: "steps", defaultValue: [] },
501
+ { name: "tags" }
502
+ ]
503
+ };
504
+ }
505
+ case "DynamicViewRulePredicate": {
506
+ return {
507
+ name: "DynamicViewRulePredicate",
508
+ properties: [
509
+ { name: "expressions", defaultValue: [] }
510
+ ]
511
+ };
512
+ }
513
+ case "DynamicViewStep": {
514
+ return {
515
+ name: "DynamicViewStep",
516
+ properties: [
517
+ { name: "isBackward", defaultValue: false },
518
+ { name: "kind" },
519
+ { name: "source" },
520
+ { name: "target" },
521
+ { name: "title" }
522
+ ]
523
+ };
524
+ }
444
525
  case "Element": {
445
526
  return {
446
527
  name: "Element",
@@ -822,6 +903,14 @@ export class LikeC4AstReflection extends AbstractAstReflection {
822
903
  ]
823
904
  };
824
905
  }
906
+ case "ViewRef": {
907
+ return {
908
+ name: "ViewRef",
909
+ properties: [
910
+ { name: "view" }
911
+ ]
912
+ };
913
+ }
825
914
  case "ViewRuleAutoLayout": {
826
915
  return {
827
916
  name: "ViewRuleAutoLayout",