@likec4/language-server 0.35.0 → 0.37.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.
@@ -1,7 +1,7 @@
1
1
  // Monarch syntax highlighting for the likec4 language.
2
2
  export default {
3
3
  keywords: [
4
- 'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','browser','color','cylinder','description','element','exclude','extend','gray','green','icon','include','indigo','it','kind','link','mobile','model','muted','of','person','primary','queue','rectangle','red','secondary','shape','sky','slate','specification','storage','style','tag','technology','this','title','view','views'
4
+ 'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','browser','color','cylinder','description','element','exclude','extend','extends','gray','green','icon','include','indigo','it','kind','link','mobile','model','muted','of','person','primary','queue','rectangle','red','secondary','shape','sky','slate','specification','storage','style','tag','technology','this','title','view','views'
5
5
  ],
6
6
  operators: [
7
7
  '*','.*'
@@ -12,7 +12,7 @@
12
12
  },
13
13
  {
14
14
  "name": "keyword.control.likec4",
15
- "match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|autoLayout|blue|browser|color|cylinder|description|element|exclude|extend|gray|green|icon|include|indigo|it|kind|link|mobile|model|muted|of|person|primary|queue|rectangle|red|secondary|shape|sky|slate|specification|storage|style|tag|technology|this|title|view|views)\\b"
15
+ "match": "\\b(BottomTop|LeftRight|RightLeft|TopBottom|amber|autoLayout|blue|browser|color|cylinder|description|element|exclude|extend|extends|gray|green|icon|include|indigo|it|kind|link|mobile|model|muted|of|person|primary|queue|rectangle|red|secondary|shape|sky|slate|specification|storage|style|tag|technology|this|title|view|views)\\b"
16
16
  },
17
17
  {
18
18
  "name": "string.quoted.double.likec4",
package/dist/ast.d.ts CHANGED
@@ -37,8 +37,9 @@ export interface ParsedAstRelation {
37
37
  }
38
38
  export interface ParsedAstElementView {
39
39
  id: c4.ViewID;
40
- astPath: string;
41
40
  viewOf?: c4.Fqn;
41
+ extends?: c4.ViewID;
42
+ astPath: string;
42
43
  title?: string;
43
44
  description?: string;
44
45
  tags?: c4.NonEmptyArray<c4.Tag>;
@@ -1,7 +1,19 @@
1
1
  import { type c4 } from '@likec4/core';
2
2
  import { ast } from './ast';
3
3
  export declare function isElementRefHead(node: ast.ElementRef | ast.StrictElementRef): boolean;
4
+ /**
5
+ * Returns referenced AST Element
6
+ *
7
+ */
4
8
  export declare function elementRef(node: ast.ElementRef | ast.StrictElementRef): ast.Element | undefined;
5
- export declare function strictElementRefFqn(node: ast.StrictElementRef): c4.Fqn;
6
- export declare function parentStrictElementRef(node: ast.StrictElementRef): c4.Fqn;
9
+ /**
10
+ * Returns FQN of strictElementRef
11
+ * a.b.c.d - for c node returns a.b
12
+ */
13
+ export declare function fqnElementRef(node: ast.StrictElementRef): c4.Fqn;
14
+ /**
15
+ * Returns parent FQN
16
+ * a.b.c.d - for c node returns a.b
17
+ */
18
+ export declare function parentFqnElementRef(node: ast.StrictElementRef): c4.Fqn;
7
19
  //# sourceMappingURL=elementRef.d.ts.map
@@ -9,6 +9,10 @@ export function isElementRefHead(node) {
9
9
  }
10
10
  nonexhaustive(node);
11
11
  }
12
+ /**
13
+ * Returns referenced AST Element
14
+ *
15
+ */
12
16
  export function elementRef(node) {
13
17
  invariant(isElementRefHead(node), 'Expected head ElementRef');
14
18
  while (node.next) {
@@ -16,7 +20,11 @@ export function elementRef(node) {
16
20
  }
17
21
  return node.el.ref;
18
22
  }
19
- export function strictElementRefFqn(node) {
23
+ /**
24
+ * Returns FQN of strictElementRef
25
+ * a.b.c.d - for c node returns a.b
26
+ */
27
+ export function fqnElementRef(node) {
20
28
  invariant(isElementRefHead(node), 'Expected head StrictElementRef');
21
29
  const name = [node.el.$refText];
22
30
  let child = node.next;
@@ -26,7 +34,11 @@ export function strictElementRefFqn(node) {
26
34
  }
27
35
  return name.join('.');
28
36
  }
29
- export function parentStrictElementRef(node) {
37
+ /**
38
+ * Returns parent FQN
39
+ * a.b.c.d - for c node returns a.b
40
+ */
41
+ export function parentFqnElementRef(node) {
30
42
  invariant(!isElementRefHead(node), 'Expected next StrictElementRef');
31
43
  const path = [];
32
44
  let parent = node.$container;
@@ -127,14 +127,29 @@ export declare function isElementTagExpression(item: unknown): item is ElementTa
127
127
  export interface ElementView extends AstNode {
128
128
  readonly $container: ModelViews;
129
129
  readonly $type: 'ElementView';
130
+ body: ElementViewBody;
131
+ extends?: ElementViewRef;
130
132
  name?: Name;
131
- props: Array<LinkProperty | ViewProperty>;
132
- rules: Array<ViewRuleAutoLayout | ViewRuleExpression | ViewRuleStyle>;
133
- tags?: Tags;
134
133
  viewOf?: ElementRef;
135
134
  }
136
135
  export declare const ElementView = "ElementView";
137
136
  export declare function isElementView(item: unknown): item is ElementView;
137
+ export interface ElementViewBody extends AstNode {
138
+ readonly $container: ElementView;
139
+ readonly $type: 'ElementViewBody';
140
+ props: Array<LinkProperty | ViewProperty>;
141
+ rules: Array<ViewRuleAutoLayout | ViewRuleExpression | ViewRuleStyle>;
142
+ tags?: Tags;
143
+ }
144
+ export declare const ElementViewBody = "ElementViewBody";
145
+ export declare function isElementViewBody(item: unknown): item is ElementViewBody;
146
+ export interface ElementViewRef extends AstNode {
147
+ readonly $container: ElementView;
148
+ readonly $type: 'ElementViewRef';
149
+ view: Reference<ElementView>;
150
+ }
151
+ export declare const ElementViewRef = "ElementViewRef";
152
+ export declare function isElementViewRef(item: unknown): item is ElementViewRef;
138
153
  export interface ExtendElement extends AstNode {
139
154
  readonly $container: Model;
140
155
  readonly $type: 'ExtendElement';
@@ -183,7 +198,7 @@ export interface LikeC4Document extends AstNode {
183
198
  export declare const LikeC4Document = "LikeC4Document";
184
199
  export declare function isLikeC4Document(item: unknown): item is LikeC4Document;
185
200
  export interface LinkProperty extends AstNode {
186
- readonly $container: ElementBody | ElementView;
201
+ readonly $container: ElementBody | ElementViewBody;
187
202
  readonly $type: 'LinkProperty';
188
203
  key: 'link';
189
204
  value: Uri;
@@ -269,8 +284,9 @@ export declare function isSpecificationElementKind(item: unknown): item is Speci
269
284
  export interface SpecificationRule extends AstNode {
270
285
  readonly $container: LikeC4Document;
271
286
  readonly $type: 'SpecificationRule';
287
+ elements: Array<SpecificationElementKind>;
272
288
  name: 'specification';
273
- specs: Array<SpecificationElementKind | SpecificationTag>;
289
+ tags: Array<SpecificationTag>;
274
290
  }
275
291
  export declare const SpecificationRule = "SpecificationRule";
276
292
  export declare function isSpecificationRule(item: unknown): item is SpecificationRule;
@@ -306,14 +322,14 @@ export interface Tag extends AstNode {
306
322
  export declare const Tag = "Tag";
307
323
  export declare function isTag(item: unknown): item is Tag;
308
324
  export interface Tags extends AstNode {
309
- readonly $container: ElementBody | ElementView | RelationBody;
325
+ readonly $container: ElementBody | ElementViewBody | RelationBody;
310
326
  readonly $type: 'Tags';
311
327
  value: Array<Reference<Tag>>;
312
328
  }
313
329
  export declare const Tags = "Tags";
314
330
  export declare function isTags(item: unknown): item is Tags;
315
331
  export interface ViewProperty extends AstNode {
316
- readonly $container: ElementView;
332
+ readonly $container: ElementViewBody;
317
333
  readonly $type: 'ViewProperty';
318
334
  key: 'description' | 'title';
319
335
  value: string;
@@ -321,14 +337,14 @@ export interface ViewProperty extends AstNode {
321
337
  export declare const ViewProperty = "ViewProperty";
322
338
  export declare function isViewProperty(item: unknown): item is ViewProperty;
323
339
  export interface ViewRuleAutoLayout extends AstNode {
324
- readonly $container: ElementView;
340
+ readonly $container: ElementViewBody;
325
341
  readonly $type: 'ViewRuleAutoLayout';
326
342
  direction: ViewRuleLayoutDirection;
327
343
  }
328
344
  export declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
329
345
  export declare function isViewRuleAutoLayout(item: unknown): item is ViewRuleAutoLayout;
330
346
  export interface ViewRuleExpression extends AstNode {
331
- readonly $container: ElementView;
347
+ readonly $container: ElementViewBody;
332
348
  readonly $type: 'ViewRuleExpression';
333
349
  expressions: Array<Expression>;
334
350
  isInclude: boolean;
@@ -336,7 +352,7 @@ export interface ViewRuleExpression extends AstNode {
336
352
  export declare const ViewRuleExpression = "ViewRuleExpression";
337
353
  export declare function isViewRuleExpression(item: unknown): item is ViewRuleExpression;
338
354
  export interface ViewRuleStyle extends AstNode {
339
- readonly $container: ElementView;
355
+ readonly $container: ElementViewBody;
340
356
  readonly $type: 'ViewRuleStyle';
341
357
  props: Array<ColorProperty | IconProperty | ShapeProperty>;
342
358
  targets: Array<ElementExpression>;
@@ -363,6 +379,8 @@ export type LikeC4AstType = {
363
379
  ElementStringProperty: ElementStringProperty;
364
380
  ElementTagExpression: ElementTagExpression;
365
381
  ElementView: ElementView;
382
+ ElementViewBody: ElementViewBody;
383
+ ElementViewRef: ElementViewRef;
366
384
  Expression: Expression;
367
385
  ExtendElement: ExtendElement;
368
386
  ExtendElementBody: ExtendElementBody;
@@ -100,6 +100,14 @@ export const ElementView = 'ElementView';
100
100
  export function isElementView(item) {
101
101
  return reflection.isInstance(item, ElementView);
102
102
  }
103
+ export const ElementViewBody = 'ElementViewBody';
104
+ export function isElementViewBody(item) {
105
+ return reflection.isInstance(item, ElementViewBody);
106
+ }
107
+ export const ElementViewRef = 'ElementViewRef';
108
+ export function isElementViewRef(item) {
109
+ return reflection.isInstance(item, ElementViewRef);
110
+ }
103
111
  export const ExtendElement = 'ExtendElement';
104
112
  export function isExtendElement(item) {
105
113
  return reflection.isInstance(item, ExtendElement);
@@ -210,7 +218,7 @@ export function isWildcardExpression(item) {
210
218
  }
211
219
  export class LikeC4AstReflection extends AbstractAstReflection {
212
220
  getAllTypes() {
213
- return ['ColorProperty', 'Element', 'ElementBody', 'ElementExpression', 'ElementKind', 'ElementKindExpression', 'ElementProperty', 'ElementRef', 'ElementRefExpression', 'ElementStringProperty', 'ElementTagExpression', 'ElementView', 'Expression', 'ExtendElement', 'ExtendElementBody', 'IconProperty', 'InOutExpression', 'IncomingExpression', 'LikeC4Document', 'LinkProperty', 'Model', 'ModelViews', 'OutgoingExpression', 'Relation', 'RelationBody', 'RelationExpression', 'RelationStringProperty', 'ShapeProperty', 'SpecificationElementKind', 'SpecificationRule', 'SpecificationTag', 'StrictElementRef', 'StyleProperties', 'Tag', 'Tags', 'View', 'ViewProperty', 'ViewRule', 'ViewRuleAutoLayout', 'ViewRuleExpression', 'ViewRuleStyle', 'WildcardExpression'];
221
+ return ['ColorProperty', 'Element', 'ElementBody', 'ElementExpression', 'ElementKind', 'ElementKindExpression', 'ElementProperty', 'ElementRef', 'ElementRefExpression', 'ElementStringProperty', 'ElementTagExpression', 'ElementView', 'ElementViewBody', 'ElementViewRef', 'Expression', 'ExtendElement', 'ExtendElementBody', 'IconProperty', 'InOutExpression', 'IncomingExpression', 'LikeC4Document', 'LinkProperty', 'Model', 'ModelViews', 'OutgoingExpression', 'Relation', 'RelationBody', 'RelationExpression', 'RelationStringProperty', 'ShapeProperty', 'SpecificationElementKind', 'SpecificationRule', 'SpecificationTag', 'StrictElementRef', 'StyleProperties', 'Tag', 'Tags', 'View', 'ViewProperty', 'ViewRule', 'ViewRuleAutoLayout', 'ViewRuleExpression', 'ViewRuleStyle', 'WildcardExpression'];
214
222
  }
215
223
  computeIsSubtype(subtype, supertype) {
216
224
  switch (subtype) {
@@ -259,6 +267,9 @@ export class LikeC4AstReflection extends AbstractAstReflection {
259
267
  case 'Tags:value': {
260
268
  return Tag;
261
269
  }
270
+ case 'ElementViewRef:view': {
271
+ return ElementView;
272
+ }
262
273
  default: {
263
274
  throw new Error(`${referenceId} is not a valid reference id.`);
264
275
  }
@@ -307,9 +318,9 @@ export class LikeC4AstReflection extends AbstractAstReflection {
307
318
  ]
308
319
  };
309
320
  }
310
- case 'ElementView': {
321
+ case 'ElementViewBody': {
311
322
  return {
312
- name: 'ElementView',
323
+ name: 'ElementViewBody',
313
324
  mandatory: [
314
325
  { name: 'props', type: 'array' },
315
326
  { name: 'rules', type: 'array' }
@@ -352,7 +363,8 @@ export class LikeC4AstReflection extends AbstractAstReflection {
352
363
  return {
353
364
  name: 'SpecificationRule',
354
365
  mandatory: [
355
- { name: 'specs', type: 'array' }
366
+ { name: 'elements', type: 'array' },
367
+ { name: 'tags', type: 'array' }
356
368
  ]
357
369
  };
358
370
  }