@likec4/language-server 1.39.5 → 1.40.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/dist/ast.d.ts +1 -0
- package/dist/bundled.mjs +3078 -3074
- package/dist/formatting/LikeC4Formatter.mjs +13 -8
- package/dist/generated/ast.d.ts +18 -3
- package/dist/generated/ast.mjs +26 -2
- package/dist/generated/grammar.mjs +1 -1
- package/dist/lsp/CompletionProvider.mjs +34 -3
- package/dist/lsp/SemanticTokenProvider.mjs +1 -1
- package/dist/model/builder/buildModel.mjs +2 -1
- package/dist/model/parser/ViewsParser.mjs +3 -1
- package/dist/validation/{dynamic-view-step.d.ts → dynamic-view.d.ts} +2 -1
- package/dist/validation/{dynamic-view-step.mjs → dynamic-view.mjs} +19 -0
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.mjs +4 -2
- package/package.json +8 -8
|
@@ -52,9 +52,10 @@ export class LikeC4CompletionProvider extends DefaultCompletionProvider {
|
|
|
52
52
|
].join("\n")
|
|
53
53
|
});
|
|
54
54
|
break;
|
|
55
|
-
case ["title", "description", "technology"].includes(keyword.value):
|
|
55
|
+
case ["title", "description", "technology", "link"].includes(keyword.value):
|
|
56
56
|
acceptor(context, {
|
|
57
57
|
label: keyword.value,
|
|
58
|
+
detail: `Insert ${keyword.value} property`,
|
|
58
59
|
kind: CompletionItemKind.Property,
|
|
59
60
|
insertTextFormat: InsertTextFormat.Snippet,
|
|
60
61
|
insertText: `${keyword.value} '\${0}'`
|
|
@@ -91,7 +92,7 @@ export class LikeC4CompletionProvider extends DefaultCompletionProvider {
|
|
|
91
92
|
acceptor(context, {
|
|
92
93
|
label: keyword.value,
|
|
93
94
|
detail: `Insert group block`,
|
|
94
|
-
kind: CompletionItemKind.
|
|
95
|
+
kind: CompletionItemKind.Module,
|
|
95
96
|
insertTextFormat: InsertTextFormat.Snippet,
|
|
96
97
|
insertText: [
|
|
97
98
|
"group '${1:Title}' {",
|
|
@@ -100,6 +101,19 @@ export class LikeC4CompletionProvider extends DefaultCompletionProvider {
|
|
|
100
101
|
].join("\n")
|
|
101
102
|
});
|
|
102
103
|
break;
|
|
104
|
+
case ["par", "parallel"].includes(keyword.value):
|
|
105
|
+
acceptor(context, {
|
|
106
|
+
label: keyword.value,
|
|
107
|
+
detail: `Insert block of parallel steps`,
|
|
108
|
+
kind: CompletionItemKind.Module,
|
|
109
|
+
insertTextFormat: InsertTextFormat.Snippet,
|
|
110
|
+
insertText: [
|
|
111
|
+
`${keyword.value} {`,
|
|
112
|
+
" $0",
|
|
113
|
+
"}"
|
|
114
|
+
].join("\n")
|
|
115
|
+
});
|
|
116
|
+
break;
|
|
103
117
|
case (keyword.value === "dynamic" && AstUtils.hasContainerOfType(context.node, ast.isModelViews)):
|
|
104
118
|
acceptor(context, {
|
|
105
119
|
label: keyword.value,
|
|
@@ -160,11 +174,28 @@ export class LikeC4CompletionProvider extends DefaultCompletionProvider {
|
|
|
160
174
|
case keyword.value === "autoLayout":
|
|
161
175
|
acceptor(context, {
|
|
162
176
|
label: keyword.value,
|
|
163
|
-
kind: CompletionItemKind.
|
|
177
|
+
kind: CompletionItemKind.Property,
|
|
164
178
|
insertTextFormat: InsertTextFormat.Snippet,
|
|
165
179
|
insertText: "autoLayout ${1|TopBottom,BottomTop,LeftRight,RightLeft|}$0"
|
|
166
180
|
});
|
|
167
181
|
break;
|
|
182
|
+
case keyword.value === "mode":
|
|
183
|
+
acceptor(context, {
|
|
184
|
+
label: keyword.value,
|
|
185
|
+
kind: CompletionItemKind.Property,
|
|
186
|
+
insertTextFormat: InsertTextFormat.Snippet,
|
|
187
|
+
insertText: "mode ${1|sequence,diagram|}$0"
|
|
188
|
+
});
|
|
189
|
+
break;
|
|
190
|
+
case ["include", "exclude"].includes(keyword.value):
|
|
191
|
+
acceptor(context, {
|
|
192
|
+
label: keyword.value,
|
|
193
|
+
kind: CompletionItemKind.Operator,
|
|
194
|
+
detail: `Insert ${keyword.value} predicate`,
|
|
195
|
+
insertTextFormat: InsertTextFormat.PlainText,
|
|
196
|
+
insertText: `${keyword.value} `
|
|
197
|
+
});
|
|
198
|
+
break;
|
|
168
199
|
default:
|
|
169
200
|
acceptor(context, {
|
|
170
201
|
label: keyword.value,
|
|
@@ -281,7 +281,7 @@ export class LikeC4SemanticTokenProvider extends AbstractSemanticTokenProvider {
|
|
|
281
281
|
}
|
|
282
282
|
return "prune";
|
|
283
283
|
}
|
|
284
|
-
if (ast.isColorProperty(node) || ast.isShapeProperty(node) || ast.isArrowProperty(node) || ast.isLineProperty(node) || ast.isBorderProperty(node) || ast.isSizeProperty(node)) {
|
|
284
|
+
if (ast.isColorProperty(node) || ast.isShapeProperty(node) || ast.isArrowProperty(node) || ast.isLineProperty(node) || ast.isBorderProperty(node) || ast.isSizeProperty(node) || ast.isDynamicViewDisplayVariantProperty(node)) {
|
|
285
285
|
acceptor({
|
|
286
286
|
node,
|
|
287
287
|
property: "key",
|
|
@@ -21,6 +21,7 @@ import {
|
|
|
21
21
|
keys,
|
|
22
22
|
map,
|
|
23
23
|
mapValues,
|
|
24
|
+
omitBy,
|
|
24
25
|
pipe,
|
|
25
26
|
prop,
|
|
26
27
|
reduce
|
|
@@ -153,7 +154,7 @@ export function buildModelData(project, docs) {
|
|
|
153
154
|
title = "Landscape view";
|
|
154
155
|
}
|
|
155
156
|
return {
|
|
156
|
-
...model,
|
|
157
|
+
...omitBy(model, (v) => v === void 0),
|
|
157
158
|
[_stage]: "parsed",
|
|
158
159
|
docUri,
|
|
159
160
|
description,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import * as c4 from "@likec4/core";
|
|
2
2
|
import { invariant, isNonEmptyArray, nonexhaustive } from "@likec4/core";
|
|
3
|
-
import { filter, isArray, isDefined, isEmpty, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
|
|
3
|
+
import { filter, find, isArray, isDefined, isEmpty, isNonNullish, isTruthy, mapToObj, pipe } from "remeda";
|
|
4
4
|
import {
|
|
5
5
|
ast,
|
|
6
6
|
parseMarkdownAsString,
|
|
@@ -241,6 +241,7 @@ export function ViewsParser(B) {
|
|
|
241
241
|
const links = this.convertLinks(body);
|
|
242
242
|
ViewOps.writeId(astNode, id);
|
|
243
243
|
const manualLayout = parseViewManualLayout(astNode);
|
|
244
|
+
const variant = find(props, ast.isDynamicViewDisplayVariantProperty)?.value;
|
|
244
245
|
return {
|
|
245
246
|
[c4._type]: "dynamic",
|
|
246
247
|
id,
|
|
@@ -249,6 +250,7 @@ export function ViewsParser(B) {
|
|
|
249
250
|
description,
|
|
250
251
|
tags,
|
|
251
252
|
links: isNonEmptyArray(links) ? links : null,
|
|
253
|
+
variant,
|
|
252
254
|
rules: [
|
|
253
255
|
...additionalStyles,
|
|
254
256
|
...body.rules.flatMap((n) => {
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type ValidationCheck } from 'langium';
|
|
2
2
|
import { ast } from '../ast';
|
|
3
3
|
import type { LikeC4Services } from '../module';
|
|
4
4
|
export declare const dynamicViewStep: (services: LikeC4Services) => ValidationCheck<ast.DynamicViewStep>;
|
|
5
|
+
export declare const dynamicViewDisplayVariant: (services: LikeC4Services) => ValidationCheck<ast.DynamicViewDisplayVariantProperty>;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import { isAncestor } from "@likec4/core";
|
|
2
|
+
import { AstUtils } from "langium";
|
|
3
|
+
import { isEmpty } from "remeda";
|
|
4
|
+
import { ast } from "../ast.mjs";
|
|
2
5
|
import { elementRef } from "../utils/elementRef.mjs";
|
|
3
6
|
import { tryOrLog } from "./_shared.mjs";
|
|
4
7
|
export const dynamicViewStep = (services) => {
|
|
@@ -27,3 +30,19 @@ export const dynamicViewStep = (services) => {
|
|
|
27
30
|
}
|
|
28
31
|
});
|
|
29
32
|
};
|
|
33
|
+
export const dynamicViewDisplayVariant = (services) => {
|
|
34
|
+
return tryOrLog((prop, accept) => {
|
|
35
|
+
if (isEmpty(prop.value) || prop.value !== "diagram" && prop.value !== "sequence") {
|
|
36
|
+
accept("error", 'Invalid display variant: "diagram" or "sequence" are allowed', {
|
|
37
|
+
node: prop,
|
|
38
|
+
property: "value"
|
|
39
|
+
});
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
if (!AstUtils.hasContainerOfType(prop, ast.isDynamicViewBody)) {
|
|
43
|
+
accept("error", `Display mode can be defined only inside dynamic view`, {
|
|
44
|
+
node: prop
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
};
|
|
@@ -4,7 +4,7 @@ import type { LikeC4Services } from '../module';
|
|
|
4
4
|
export { LikeC4DocumentValidator } from './DocumentValidator';
|
|
5
5
|
type Guard<N extends AstNode> = (n: AstNode) => n is N;
|
|
6
6
|
type Guarded<G> = G extends Guard<infer N> ? N : never;
|
|
7
|
-
declare const isValidatableAstNode: (n: AstNode) => n is ast.HexColor | ast.RGBAColor | ast.DeployedInstance | ast.DeploymentNode | ast.DeploymentViewRulePredicate | ast.DeploymentViewRuleStyle | ast.ViewRuleAutoLayout | ast.DynamicViewGlobalPredicateRef | ast.DynamicViewIncludePredicate | ast.ViewRuleGlobalStyle | ast.ViewRuleStyle | ast.ElementStringProperty | ast.ElementStyleProperty | ast.IconProperty | ast.
|
|
7
|
+
declare const isValidatableAstNode: (n: AstNode) => n is ast.HexColor | ast.RGBAColor | ast.DeployedInstance | ast.DeploymentNode | ast.DeploymentViewRulePredicate | ast.DeploymentViewRuleStyle | ast.ViewRuleAutoLayout | ast.DynamicViewDisplayVariantProperty | ast.LinkProperty | ast.ViewStringProperty | ast.DynamicViewGlobalPredicateRef | ast.DynamicViewIncludePredicate | ast.ViewRuleGlobalStyle | ast.ViewRuleStyle | ast.ElementStringProperty | ast.ElementStyleProperty | ast.IconProperty | ast.MetadataBody | ast.ElementKindExpression | ast.ElementTagExpression | ast.FqnRefExpr | ast.WildcardExpression | ast.FqnExprWhere | ast.FqnExprWith | ast.DirectedRelationExpr | ast.InOutRelationExpr | ast.IncomingRelationExpr | ast.OutgoingRelationExpr | ast.RelationExprWhere | ast.RelationExprWith | ast.Element | ast.ExtendDeployment | ast.ExtendElement | ast.Imported | ast.DeploymentView | ast.DynamicView | ast.ElementView | ast.RelationStringProperty | ast.ArrowProperty | ast.ColorProperty | ast.LineProperty | ast.PaddingSizeProperty | ast.ShapeSizeProperty | ast.TextSizeProperty | ast.MetadataAttribute | ast.NotationProperty | ast.NotesProperty | ast.SpecificationElementStringProperty | ast.SpecificationRelationshipStringProperty | ast.BorderProperty | ast.MultipleProperty | ast.OpacityProperty | ast.ShapeProperty | ast.ViewRuleGlobalPredicateRef | ast.ViewRuleGroup | ast.ViewRulePredicate | ast.SpecificationRelationshipKind | ast.GlobalStyle | ast.SpecificationColor | ast.NavigateToProperty | ast.DynamicViewStep | ast.ElementRef | ast.DeploymentRelation | ast.Tags | ast.SpecificationDeploymentNodeKind | ast.DynamicViewParallelSteps | ast.GlobalDynamicPredicateGroup | ast.Relation | ast.SpecificationElementKind | ast.Globals | ast.GlobalPredicateGroup | ast.GlobalStyleGroup | ast.SpecificationTag | ast.ImportsFromPoject | ast.SpecificationRule;
|
|
8
8
|
type ValidatableAstNode = Guarded<typeof isValidatableAstNode>;
|
|
9
9
|
export declare function checksFromDiagnostics(doc: LikeC4LangiumDocument): {
|
|
10
10
|
isValid: (n: ValidatableAstNode) => boolean;
|
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
deploymentRelationChecks,
|
|
10
10
|
extendDeploymentChecks
|
|
11
11
|
} from "./deployment-checks.mjs";
|
|
12
|
-
import { dynamicViewStep } from "./dynamic-view
|
|
12
|
+
import { dynamicViewDisplayVariant, dynamicViewStep } from "./dynamic-view.mjs";
|
|
13
13
|
import { checkElement } from "./element.mjs";
|
|
14
14
|
import { checkElementRef } from "./element-ref.mjs";
|
|
15
15
|
import { checkImported, checkImportsFromPoject } from "./imports.mjs";
|
|
@@ -74,6 +74,7 @@ const isValidatableAstNode = validatableAstNodeGuards([
|
|
|
74
74
|
ast.isDeploymentNode,
|
|
75
75
|
ast.isDeploymentRelation,
|
|
76
76
|
ast.isRelationshipStyleProperty,
|
|
77
|
+
ast.isDynamicViewDisplayVariantProperty,
|
|
77
78
|
ast.isMetadataProperty,
|
|
78
79
|
ast.isRelation,
|
|
79
80
|
ast.isElementProperty,
|
|
@@ -155,7 +156,8 @@ export function registerValidationChecks(services) {
|
|
|
155
156
|
OutgoingRelationExpr: checkOutgoingRelationExpr(services),
|
|
156
157
|
ImportsFromPoject: checkImportsFromPoject(services),
|
|
157
158
|
Imported: checkImported(services),
|
|
158
|
-
ColorLiteral: colorLiteralRuleChecks(services)
|
|
159
|
+
ColorLiteral: colorLiteralRuleChecks(services),
|
|
160
|
+
DynamicViewDisplayVariantProperty: dynamicViewDisplayVariant(services)
|
|
159
161
|
});
|
|
160
162
|
const connection = services.shared.lsp.Connection;
|
|
161
163
|
if (connection) {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/language-server",
|
|
3
3
|
"description": "LikeC4 Language Server",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.40.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -112,7 +112,7 @@
|
|
|
112
112
|
"langium-cli": "3.5.2",
|
|
113
113
|
"natural-compare-lite": "^1.4.0",
|
|
114
114
|
"p-debounce": "4.0.0",
|
|
115
|
-
"p-queue": "8.1.
|
|
115
|
+
"p-queue": "8.1.1",
|
|
116
116
|
"p-timeout": "6.1.4",
|
|
117
117
|
"picomatch": "^4.0.3",
|
|
118
118
|
"pretty-ms": "^9.2.0",
|
|
@@ -132,12 +132,12 @@
|
|
|
132
132
|
"vscode-uri": "3.1.0",
|
|
133
133
|
"which": "^5.0.0",
|
|
134
134
|
"zod": "3.25.76",
|
|
135
|
-
"@likec4/core": "1.
|
|
136
|
-
"@likec4/config": "1.
|
|
137
|
-
"@likec4/icons": "1.
|
|
138
|
-
"@likec4/layouts": "1.
|
|
139
|
-
"@likec4/
|
|
140
|
-
"@likec4/
|
|
135
|
+
"@likec4/core": "1.40.0",
|
|
136
|
+
"@likec4/config": "1.40.0",
|
|
137
|
+
"@likec4/icons": "1.40.0",
|
|
138
|
+
"@likec4/layouts": "1.40.0",
|
|
139
|
+
"@likec4/log": "1.40.0",
|
|
140
|
+
"@likec4/tsconfig": "1.40.0"
|
|
141
141
|
},
|
|
142
142
|
"scripts": {
|
|
143
143
|
"typecheck": "tsc -b --verbose",
|