@likec4/language-server 0.36.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.
- package/contrib/likec4.monarch.ts +1 -1
- package/contrib/likec4.tmLanguage.json +1 -1
- package/dist/ast.d.ts +2 -1
- package/dist/elementRef.d.ts +14 -2
- package/dist/elementRef.js +14 -2
- package/dist/generated/ast.d.ts +26 -9
- package/dist/generated/ast.js +14 -3
- package/dist/generated/grammar.js +235 -143
- package/dist/lsp/SemanticTokenProvider.js +14 -13
- package/dist/model/fqn-computation.js +2 -2
- package/dist/model/fqn-index.js +4 -6
- package/dist/model/model-builder.d.ts +3 -1
- package/dist/model/model-builder.js +56 -33
- package/dist/model/model-locator.js +1 -1
- package/dist/model/model-parser.js +31 -15
- package/dist/protocol.d.ts +10 -2
- package/dist/protocol.js +5 -1
- package/dist/references/scope-provider.js +13 -7
- package/dist/registerProtocolHandlers.js +16 -0
- package/dist/validation/view.js +3 -0
- package/package.json +2 -2
|
@@ -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>;
|
package/dist/elementRef.d.ts
CHANGED
|
@@ -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
|
-
|
|
6
|
-
|
|
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
|
package/dist/elementRef.js
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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;
|
package/dist/generated/ast.d.ts
CHANGED
|
@@ -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 |
|
|
201
|
+
readonly $container: ElementBody | ElementViewBody;
|
|
187
202
|
readonly $type: 'LinkProperty';
|
|
188
203
|
key: 'link';
|
|
189
204
|
value: Uri;
|
|
@@ -307,14 +322,14 @@ export interface Tag extends AstNode {
|
|
|
307
322
|
export declare const Tag = "Tag";
|
|
308
323
|
export declare function isTag(item: unknown): item is Tag;
|
|
309
324
|
export interface Tags extends AstNode {
|
|
310
|
-
readonly $container: ElementBody |
|
|
325
|
+
readonly $container: ElementBody | ElementViewBody | RelationBody;
|
|
311
326
|
readonly $type: 'Tags';
|
|
312
327
|
value: Array<Reference<Tag>>;
|
|
313
328
|
}
|
|
314
329
|
export declare const Tags = "Tags";
|
|
315
330
|
export declare function isTags(item: unknown): item is Tags;
|
|
316
331
|
export interface ViewProperty extends AstNode {
|
|
317
|
-
readonly $container:
|
|
332
|
+
readonly $container: ElementViewBody;
|
|
318
333
|
readonly $type: 'ViewProperty';
|
|
319
334
|
key: 'description' | 'title';
|
|
320
335
|
value: string;
|
|
@@ -322,14 +337,14 @@ export interface ViewProperty extends AstNode {
|
|
|
322
337
|
export declare const ViewProperty = "ViewProperty";
|
|
323
338
|
export declare function isViewProperty(item: unknown): item is ViewProperty;
|
|
324
339
|
export interface ViewRuleAutoLayout extends AstNode {
|
|
325
|
-
readonly $container:
|
|
340
|
+
readonly $container: ElementViewBody;
|
|
326
341
|
readonly $type: 'ViewRuleAutoLayout';
|
|
327
342
|
direction: ViewRuleLayoutDirection;
|
|
328
343
|
}
|
|
329
344
|
export declare const ViewRuleAutoLayout = "ViewRuleAutoLayout";
|
|
330
345
|
export declare function isViewRuleAutoLayout(item: unknown): item is ViewRuleAutoLayout;
|
|
331
346
|
export interface ViewRuleExpression extends AstNode {
|
|
332
|
-
readonly $container:
|
|
347
|
+
readonly $container: ElementViewBody;
|
|
333
348
|
readonly $type: 'ViewRuleExpression';
|
|
334
349
|
expressions: Array<Expression>;
|
|
335
350
|
isInclude: boolean;
|
|
@@ -337,7 +352,7 @@ export interface ViewRuleExpression extends AstNode {
|
|
|
337
352
|
export declare const ViewRuleExpression = "ViewRuleExpression";
|
|
338
353
|
export declare function isViewRuleExpression(item: unknown): item is ViewRuleExpression;
|
|
339
354
|
export interface ViewRuleStyle extends AstNode {
|
|
340
|
-
readonly $container:
|
|
355
|
+
readonly $container: ElementViewBody;
|
|
341
356
|
readonly $type: 'ViewRuleStyle';
|
|
342
357
|
props: Array<ColorProperty | IconProperty | ShapeProperty>;
|
|
343
358
|
targets: Array<ElementExpression>;
|
|
@@ -364,6 +379,8 @@ export type LikeC4AstType = {
|
|
|
364
379
|
ElementStringProperty: ElementStringProperty;
|
|
365
380
|
ElementTagExpression: ElementTagExpression;
|
|
366
381
|
ElementView: ElementView;
|
|
382
|
+
ElementViewBody: ElementViewBody;
|
|
383
|
+
ElementViewRef: ElementViewRef;
|
|
367
384
|
Expression: Expression;
|
|
368
385
|
ExtendElement: ExtendElement;
|
|
369
386
|
ExtendElementBody: ExtendElementBody;
|
package/dist/generated/ast.js
CHANGED
|
@@ -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 '
|
|
321
|
+
case 'ElementViewBody': {
|
|
311
322
|
return {
|
|
312
|
-
name: '
|
|
323
|
+
name: 'ElementViewBody',
|
|
313
324
|
mandatory: [
|
|
314
325
|
{ name: 'props', type: 'array' },
|
|
315
326
|
{ name: 'rules', type: 'array' }
|