@likec4/language-server 1.20.3 → 1.21.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/README.md +1 -1
- package/dist/ast.d.ts +16 -0
- package/dist/ast.js +42 -10
- package/dist/bundled.mjs +2845 -2828
- package/dist/formatting/LikeC4Formatter.js +6 -3
- package/dist/generated/ast.d.ts +76 -24
- package/dist/generated/ast.js +103 -25
- package/dist/generated/grammar.js +1 -1
- package/dist/lsp/CompletionProvider.js +2 -1
- package/dist/lsp/SemanticTokenProvider.js +50 -2
- package/dist/model/model-builder.js +57 -3
- package/dist/model/model-parser.d.ts +6 -0
- package/dist/model/model-parser.js +1 -0
- package/dist/model/parser/Base.js +11 -5
- package/dist/model/parser/DeploymentModelParser.d.ts +1 -0
- package/dist/model/parser/DeploymentViewParser.d.ts +1 -0
- package/dist/model/parser/DeploymentViewParser.js +3 -0
- package/dist/model/parser/FqnRefParser.d.ts +1 -0
- package/dist/model/parser/FqnRefParser.js +10 -0
- package/dist/model/parser/GlobalsParser.d.ts +1 -0
- package/dist/model/parser/ModelParser.d.ts +2 -1
- package/dist/model/parser/ModelParser.js +26 -1
- package/dist/model/parser/PredicatesParser.js +19 -1
- package/dist/model/parser/ViewsParser.d.ts +1 -0
- package/dist/references/scope-provider.d.ts +1 -1
- package/dist/references/scope-provider.js +1 -1
- package/dist/test/testServices.d.ts +1 -0
- package/dist/test/testServices.js +8 -0
- package/dist/utils/elementRef.d.ts +3 -3
- package/dist/validation/index.d.ts +1 -1
- package/package.json +12 -12
- package/src/ast.ts +55 -9
- package/src/formatting/LikeC4Formatter.ts +7 -1
- package/src/generated/ast.ts +200 -49
- package/src/generated/grammar.ts +1 -1
- package/src/like-c4.langium +45 -7
- package/src/lsp/CompletionProvider.ts +1 -0
- package/src/lsp/SemanticTokenProvider.ts +56 -1
- package/src/model/model-builder.ts +65 -6
- package/src/model/model-parser.ts +1 -0
- package/src/model/parser/Base.ts +11 -5
- package/src/model/parser/DeploymentViewParser.ts +3 -0
- package/src/model/parser/FqnRefParser.ts +11 -0
- package/src/model/parser/ModelParser.ts +30 -1
- package/src/model/parser/PredicatesParser.ts +19 -1
- package/src/references/scope-provider.ts +9 -9
- package/src/test/testServices.ts +18 -9
- package/src/utils/elementRef.ts +3 -3
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# `@likec4/language-server`
|
|
2
2
|
|
|
3
|
-
[docs](https://likec4.dev/) | [playground](https://playground.likec4.dev/) | [demo](https://template.likec4.dev/view/
|
|
3
|
+
[docs](https://likec4.dev/) | [playground](https://playground.likec4.dev/) | [demo](https://template.likec4.dev/view/index/)
|
|
4
4
|
|
|
5
5
|
Language Server Protocol (LSP) based on [languim](https://github.com/languim/languim) library.
|
|
6
6
|
|
package/dist/ast.d.ts
CHANGED
|
@@ -34,6 +34,9 @@ type ParsedElementStyle = {
|
|
|
34
34
|
border?: c4.BorderStyle;
|
|
35
35
|
opacity?: number;
|
|
36
36
|
multiple?: boolean;
|
|
37
|
+
size?: c4.ShapeSize;
|
|
38
|
+
padding?: c4.SpacingSize;
|
|
39
|
+
textSize?: c4.TextSize;
|
|
37
40
|
};
|
|
38
41
|
export interface ParsedAstSpecification {
|
|
39
42
|
tags: Set<c4.Tag>;
|
|
@@ -69,6 +72,15 @@ export interface ParsedAstElement {
|
|
|
69
72
|
[key: string]: string;
|
|
70
73
|
};
|
|
71
74
|
}
|
|
75
|
+
export interface ParsedAstExtendElement {
|
|
76
|
+
id: c4.Fqn;
|
|
77
|
+
astPath: string;
|
|
78
|
+
tags?: c4.NonEmptyArray<c4.Tag>;
|
|
79
|
+
links?: c4.NonEmptyArray<ParsedLink>;
|
|
80
|
+
metadata?: {
|
|
81
|
+
[key: string]: string;
|
|
82
|
+
};
|
|
83
|
+
}
|
|
72
84
|
export interface ParsedAstRelation {
|
|
73
85
|
id: c4.RelationId;
|
|
74
86
|
astPath: string;
|
|
@@ -158,6 +170,7 @@ export interface LikeC4DocumentProps {
|
|
|
158
170
|
diagnostics?: Array<LikeC4DocumentDiagnostic>;
|
|
159
171
|
c4Specification?: ParsedAstSpecification;
|
|
160
172
|
c4Elements?: ParsedAstElement[];
|
|
173
|
+
c4ExtendElements?: ParsedAstExtendElement[];
|
|
161
174
|
c4Relations?: ParsedAstRelation[];
|
|
162
175
|
c4Globals?: ParsedAstGlobals;
|
|
163
176
|
c4Views?: ParsedAstView[];
|
|
@@ -182,6 +195,9 @@ export declare function resolveRelationPoints(node: ast.Relation): {
|
|
|
182
195
|
target: ast.Element;
|
|
183
196
|
};
|
|
184
197
|
export declare function parseAstOpacityProperty({ value }: ast.OpacityProperty): number;
|
|
198
|
+
export declare function parseAstSizeValue({ value }: {
|
|
199
|
+
value: ast.SizeValue;
|
|
200
|
+
}): 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
185
201
|
export declare function toElementStyle(props: Array<ast.StyleProperty> | undefined, isValid: IsValidFn): ParsedElementStyle;
|
|
186
202
|
export declare function toRelationshipStyle(props: ast.RelationshipStyleProperty[] | undefined, isValid: IsValidFn): {
|
|
187
203
|
color?: c4.Color;
|
package/dist/ast.js
CHANGED
|
@@ -35,7 +35,7 @@ export function isFqnIndexedDocument(doc) {
|
|
|
35
35
|
return isLikeC4LangiumDocument(doc) && doc.state >= DocumentState.IndexedContent && !!doc.c4fqnIndex;
|
|
36
36
|
}
|
|
37
37
|
export function isParsedLikeC4LangiumDocument(doc) {
|
|
38
|
-
return isLikeC4LangiumDocument(doc) && doc.state == DocumentState.Validated && !!doc.c4Specification && !!doc.c4Elements && !!doc.c4Relations && !!doc.c4Views && !!doc.c4fqnIndex && !!doc.c4Deployments && !!doc.c4DeploymentRelations;
|
|
38
|
+
return isLikeC4LangiumDocument(doc) && doc.state == DocumentState.Validated && !!doc.c4Specification && !!doc.c4Elements && !!doc.c4ExtendElements && !!doc.c4Relations && !!doc.c4Views && !!doc.c4fqnIndex && !!doc.c4Deployments && !!doc.c4DeploymentRelations;
|
|
39
39
|
}
|
|
40
40
|
export function* streamModel(doc) {
|
|
41
41
|
const traverseStack = LinkedList.from(doc.parseResult.value.models.flatMap((m) => m.elements));
|
|
@@ -46,15 +46,7 @@ export function* streamModel(doc) {
|
|
|
46
46
|
relations.push(el);
|
|
47
47
|
continue;
|
|
48
48
|
}
|
|
49
|
-
if (
|
|
50
|
-
if (el.body && el.body.elements.length > 0) {
|
|
51
|
-
for (const child of el.body.elements) {
|
|
52
|
-
traverseStack.push(child);
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
continue;
|
|
56
|
-
}
|
|
57
|
-
if (el.body && el.body.elements.length > 0) {
|
|
49
|
+
if (el.body && el.body.elements && el.body.elements.length > 0) {
|
|
58
50
|
for (const child of el.body.elements) {
|
|
59
51
|
traverseStack.push(child);
|
|
60
52
|
}
|
|
@@ -112,6 +104,28 @@ export function parseAstOpacityProperty({ value }) {
|
|
|
112
104
|
const opacity = parseFloat(value);
|
|
113
105
|
return isNaN(opacity) ? 100 : clamp(opacity, { min: 0, max: 100 });
|
|
114
106
|
}
|
|
107
|
+
export function parseAstSizeValue({ value }) {
|
|
108
|
+
switch (value) {
|
|
109
|
+
case "xs":
|
|
110
|
+
case "sm":
|
|
111
|
+
case "md":
|
|
112
|
+
case "lg":
|
|
113
|
+
case "xl":
|
|
114
|
+
return value;
|
|
115
|
+
case "xsmall":
|
|
116
|
+
return "xs";
|
|
117
|
+
case "small":
|
|
118
|
+
return "sm";
|
|
119
|
+
case "medium":
|
|
120
|
+
return "md";
|
|
121
|
+
case "large":
|
|
122
|
+
return "lg";
|
|
123
|
+
case "xlarge":
|
|
124
|
+
return "xl";
|
|
125
|
+
default:
|
|
126
|
+
nonexhaustive(value);
|
|
127
|
+
}
|
|
128
|
+
}
|
|
115
129
|
export function toElementStyle(props, isValid) {
|
|
116
130
|
const result = {};
|
|
117
131
|
if (!props || props.length === 0) {
|
|
@@ -156,6 +170,24 @@ export function toElementStyle(props, isValid) {
|
|
|
156
170
|
result.multiple = isBoolean(prop.value) ? prop.value : false;
|
|
157
171
|
break;
|
|
158
172
|
}
|
|
173
|
+
case ast.isShapeSizeProperty(prop): {
|
|
174
|
+
if (isTruthy(prop.value)) {
|
|
175
|
+
result.size = parseAstSizeValue(prop);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case ast.isPaddingSizeProperty(prop): {
|
|
180
|
+
if (isTruthy(prop.value)) {
|
|
181
|
+
result.padding = parseAstSizeValue(prop);
|
|
182
|
+
}
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case ast.isTextSizeProperty(prop): {
|
|
186
|
+
if (isTruthy(prop.value)) {
|
|
187
|
+
result.textSize = parseAstSizeValue(prop);
|
|
188
|
+
}
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
159
191
|
default:
|
|
160
192
|
nonexhaustive(prop);
|
|
161
193
|
}
|