@likec4/language-server 0.23.0 → 0.25.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 +3 -3
- package/dist/ast.d.ts +1 -2
- package/dist/ast.js +6 -6
- package/dist/elementRef.js +1 -0
- package/dist/generated/ast.d.ts +8 -0
- package/dist/generated/ast.js +3 -0
- package/dist/generated/grammar.js +223 -144
- package/dist/lsp/DocumentSymbolProvider.d.ts +1 -1
- package/dist/lsp/DocumentSymbolProvider.js +1 -1
- package/dist/lsp/HoverProvider.d.ts +1 -1
- package/dist/lsp/SemanticTokenProvider.js +23 -24
- package/dist/model/model-builder.d.ts +2 -1
- package/dist/model/model-builder.js +26 -13
- package/dist/module.js +24 -9
- package/dist/protocol.d.ts +2 -2
- package/dist/protocol.js +2 -2
- package/dist/references/scope-computation.js +4 -6
- package/dist/registerProtocolHandlers.js +6 -21
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +4 -4
|
@@ -4,16 +4,16 @@ export default {
|
|
|
4
4
|
'BottomTop','LeftRight','RightLeft','TopBottom','amber','autoLayout','blue','browser','color','cylinder','description','element','exclude','extend','gray','green','include','indigo','it','kind','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
|
+
'*','.*'
|
|
8
8
|
],
|
|
9
|
-
symbols:
|
|
9
|
+
symbols: /\*|\.\*/,
|
|
10
10
|
|
|
11
11
|
tokenizer: {
|
|
12
12
|
initial: [
|
|
13
|
+
{ regex: /"[^"]*"|'[^']*'/, action: {"token":"string"} },
|
|
13
14
|
{ regex: /[^\W\d_]/, action: { cases: { '@keywords': {"token":"keyword"}, '@default': {"token":"LETTER"} }} },
|
|
14
15
|
{ regex: /[0-9]/, action: {"token":"DIGIT"} },
|
|
15
16
|
{ regex: /[\t\r\n\v\f]/, action: {"token":"NEWLINE"} },
|
|
16
|
-
{ regex: /"[^"]*"|'[^']*'/, action: {"token":"string"} },
|
|
17
17
|
{ include: '@whitespace' },
|
|
18
18
|
{ regex: /@symbols/, action: { cases: { '@operators': {"token":"operator"}, '@default': {"token":""} }} },
|
|
19
19
|
],
|
package/dist/ast.d.ts
CHANGED
|
@@ -46,7 +46,6 @@ export declare const ElementOps: {
|
|
|
46
46
|
readId(node: ast.Element): c4.Fqn | undefined;
|
|
47
47
|
};
|
|
48
48
|
export interface LikeC4LangiumDocument extends LangiumDocument<LikeC4Document> {
|
|
49
|
-
c4hash?: string;
|
|
50
49
|
c4Specification: ParsedAstSpecification;
|
|
51
50
|
c4Elements: ParsedAstElement[];
|
|
52
51
|
c4Relations: ParsedAstRelation[];
|
|
@@ -61,7 +60,7 @@ export declare function cleanParsedModel(doc: LikeC4LangiumDocument): {
|
|
|
61
60
|
};
|
|
62
61
|
export declare function isLikeC4LangiumDocument(doc: LangiumDocument): doc is LikeC4LangiumDocument;
|
|
63
62
|
export declare function isParsedLikeC4LangiumDocument(doc: LangiumDocument): doc is LikeC4LangiumDocument;
|
|
64
|
-
export declare const
|
|
63
|
+
export declare const isValidLikeC4LangiumDocument: (doc: LangiumDocument) => doc is LikeC4LangiumDocument;
|
|
65
64
|
export declare function streamModel(doc: LikeC4LangiumDocument): Generator<ast.Relation | ast.Element, void, unknown>;
|
|
66
65
|
export declare function resolveRelationPoints(node: ast.Relation): {
|
|
67
66
|
source: ast.Element;
|
package/dist/ast.js
CHANGED
|
@@ -28,11 +28,12 @@ export const ElementViewOps = {
|
|
|
28
28
|
};
|
|
29
29
|
export const ElementOps = {
|
|
30
30
|
writeId(node, id) {
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
32
31
|
if (id === null) {
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any, @typescript-eslint/no-dynamic-delete
|
|
33
33
|
delete node[idattr];
|
|
34
34
|
}
|
|
35
35
|
else {
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
36
37
|
node[idattr] = id;
|
|
37
38
|
}
|
|
38
39
|
return node;
|
|
@@ -63,8 +64,8 @@ export function isParsedLikeC4LangiumDocument(doc) {
|
|
|
63
64
|
return (isLikeC4LangiumDocument(doc) &&
|
|
64
65
|
['c4Specification', 'c4Elements', 'c4Relations', 'c4Views'].every(key => key in doc));
|
|
65
66
|
}
|
|
66
|
-
export const
|
|
67
|
-
if (!
|
|
67
|
+
export const isValidLikeC4LangiumDocument = (doc) => {
|
|
68
|
+
if (!isParsedLikeC4LangiumDocument(doc))
|
|
68
69
|
return false;
|
|
69
70
|
const { state, parseResult, diagnostics } = doc;
|
|
70
71
|
return (state === DocumentState.Validated &&
|
|
@@ -87,7 +88,7 @@ export function* streamModel(doc) {
|
|
|
87
88
|
}
|
|
88
89
|
continue;
|
|
89
90
|
}
|
|
90
|
-
if (
|
|
91
|
+
if (el.body && el.body.elements.length > 0) {
|
|
91
92
|
for (const nested of el.body.elements) {
|
|
92
93
|
if (ast.isRelation(nested)) {
|
|
93
94
|
relations.push(nested);
|
|
@@ -121,9 +122,8 @@ export function resolveRelationPoints(node) {
|
|
|
121
122
|
if (!ast.isElementBody(node.$container)) {
|
|
122
123
|
throw new Error('Skip relation due to invalid reference to source');
|
|
123
124
|
}
|
|
124
|
-
const source = node.$container.$container;
|
|
125
125
|
return {
|
|
126
|
-
source,
|
|
126
|
+
source: node.$container.$container,
|
|
127
127
|
target
|
|
128
128
|
};
|
|
129
129
|
}
|
package/dist/elementRef.js
CHANGED
package/dist/generated/ast.d.ts
CHANGED
|
@@ -23,6 +23,8 @@ export declare const Expression = "Expression";
|
|
|
23
23
|
export declare function isExpression(item: unknown): item is Expression;
|
|
24
24
|
export type Name = 'element' | 'model' | ElementShape | ThemeColor | string;
|
|
25
25
|
export declare function isName(item: unknown): item is Name;
|
|
26
|
+
export type RArrow = string;
|
|
27
|
+
export declare function isRArrow(item: unknown): item is RArrow;
|
|
26
28
|
export type ThemeColor = 'amber' | 'blue' | 'gray' | 'green' | 'indigo' | 'muted' | 'primary' | 'red' | 'secondary' | 'sky' | 'slate';
|
|
27
29
|
export declare function isThemeColor(item: unknown): item is ThemeColor;
|
|
28
30
|
export type View = ElementView;
|
|
@@ -143,6 +145,7 @@ export declare function isExtendElementBody(item: unknown): item is ExtendElemen
|
|
|
143
145
|
export interface IncomingExpression extends AstNode {
|
|
144
146
|
readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
|
|
145
147
|
readonly $type: 'IncomingExpression';
|
|
148
|
+
arr: RArrow;
|
|
146
149
|
target: ElementExpression;
|
|
147
150
|
}
|
|
148
151
|
export declare const IncomingExpression = "IncomingExpression";
|
|
@@ -150,6 +153,7 @@ export declare function isIncomingExpression(item: unknown): item is IncomingExp
|
|
|
150
153
|
export interface InOutExpression extends AstNode {
|
|
151
154
|
readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
|
|
152
155
|
readonly $type: 'InOutExpression';
|
|
156
|
+
arr: RArrow;
|
|
153
157
|
inout: IncomingExpression;
|
|
154
158
|
}
|
|
155
159
|
export declare const InOutExpression = "InOutExpression";
|
|
@@ -181,6 +185,7 @@ export declare function isModelViews(item: unknown): item is ModelViews;
|
|
|
181
185
|
export interface OutgoingExpression extends AstNode {
|
|
182
186
|
readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
|
|
183
187
|
readonly $type: 'OutgoingExpression';
|
|
188
|
+
arr: RArrow;
|
|
184
189
|
source: ElementExpression;
|
|
185
190
|
}
|
|
186
191
|
export declare const OutgoingExpression = "OutgoingExpression";
|
|
@@ -188,6 +193,7 @@ export declare function isOutgoingExpression(item: unknown): item is OutgoingExp
|
|
|
188
193
|
export interface Relation extends AstNode {
|
|
189
194
|
readonly $container: ElementBody | ExtendElementBody | Model;
|
|
190
195
|
readonly $type: 'Relation' | 'RelationWithSource';
|
|
196
|
+
arr: RArrow;
|
|
191
197
|
definition?: RelationBody;
|
|
192
198
|
target: ElementRef;
|
|
193
199
|
title?: string;
|
|
@@ -205,6 +211,7 @@ export declare function isRelationBody(item: unknown): item is RelationBody;
|
|
|
205
211
|
export interface RelationExpression extends AstNode {
|
|
206
212
|
readonly $container: InOutExpression | IncomingExpression | OutgoingExpression | RelationExpression | ViewRuleExpression | ViewRuleStyle;
|
|
207
213
|
readonly $type: 'RelationExpression';
|
|
214
|
+
arr: RArrow;
|
|
208
215
|
source: ElementExpression;
|
|
209
216
|
target: ElementExpression;
|
|
210
217
|
}
|
|
@@ -328,6 +335,7 @@ export declare function isWildcardExpression(item: unknown): item is WildcardExp
|
|
|
328
335
|
export interface RelationWithSource extends Relation {
|
|
329
336
|
readonly $container: ElementBody | ExtendElementBody | Model;
|
|
330
337
|
readonly $type: 'RelationWithSource';
|
|
338
|
+
arr: RArrow;
|
|
331
339
|
definition?: RelationBody;
|
|
332
340
|
source: ElementRef;
|
|
333
341
|
target: ElementRef;
|
package/dist/generated/ast.js
CHANGED
|
@@ -29,6 +29,9 @@ export function isExpression(item) {
|
|
|
29
29
|
export function isName(item) {
|
|
30
30
|
return isElementShape(item) || isThemeColor(item) || item === 'element' || item === 'model' || (typeof item === 'string' && (/((([^\W\d_])|(_))((([^\W\d_])|([0-9]))|(_))*)/.test(item)));
|
|
31
31
|
}
|
|
32
|
+
export function isRArrow(item) {
|
|
33
|
+
return (typeof item === 'string' && (/->/.test(item)));
|
|
34
|
+
}
|
|
32
35
|
export function isThemeColor(item) {
|
|
33
36
|
return item === 'primary' || item === 'secondary' || item === 'muted' || item === 'slate' || item === 'blue' || item === 'indigo' || item === 'sky' || item === 'red' || item === 'gray' || item === 'green' || item === 'amber';
|
|
34
37
|
}
|