@likec4/language-server 1.27.3 → 1.28.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/LikeC4LanguageServices.js +6 -7
- package/dist/ast.d.ts +16 -9
- package/dist/ast.js +58 -79
- package/dist/bundled.mjs +2130 -2127
- package/dist/config/schema.d.ts +3 -3
- package/dist/config/schema.js +12 -5
- package/dist/documentation/documentation-provider.js +3 -1
- package/dist/formatting/LikeC4Formatter.d.ts +0 -2
- package/dist/formatting/LikeC4Formatter.js +24 -53
- package/dist/generated/ast.d.ts +128 -233
- package/dist/generated/ast.js +134 -306
- package/dist/generated/grammar.js +1 -1
- package/dist/lsp/CompletionProvider.d.ts +3 -0
- package/dist/lsp/CompletionProvider.js +128 -113
- package/dist/lsp/DocumentLinkProvider.js +6 -3
- package/dist/lsp/HoverProvider.js +3 -1
- package/dist/lsp/SemanticTokenProvider.js +33 -43
- package/dist/model/builder/MergedSpecification.d.ts +5 -3
- package/dist/model/builder/MergedSpecification.js +21 -7
- package/dist/model/builder/buildModel.d.ts +6 -1
- package/dist/model/builder/buildModel.js +20 -15
- package/dist/model/deployments-index.js +4 -2
- package/dist/model/fqn-index.d.ts +4 -2
- package/dist/model/fqn-index.js +28 -5
- package/dist/model/model-builder.d.ts +2 -2
- package/dist/model/model-builder.js +54 -16
- package/dist/model/model-locator.js +7 -4
- package/dist/model/model-parser.d.ts +215 -52
- package/dist/model/model-parser.js +6 -2
- package/dist/model/parser/Base.d.ts +11 -2
- package/dist/model/parser/Base.js +138 -3
- package/dist/model/parser/DeploymentModelParser.d.ts +19 -2
- package/dist/model/parser/DeploymentModelParser.js +19 -29
- package/dist/model/parser/DeploymentViewParser.d.ts +18 -2
- package/dist/model/parser/DeploymentViewParser.js +6 -24
- package/dist/model/parser/FqnRefParser.d.ts +18 -3
- package/dist/model/parser/FqnRefParser.js +264 -40
- package/dist/model/parser/GlobalsParser.d.ts +35 -18
- package/dist/model/parser/ImportsParser.d.ts +32 -0
- package/dist/model/parser/ImportsParser.js +26 -0
- package/dist/model/parser/ModelParser.d.ts +26 -2
- package/dist/model/parser/ModelParser.js +21 -41
- package/dist/model/parser/PredicatesParser.d.ts +35 -12
- package/dist/model/parser/PredicatesParser.js +20 -271
- package/dist/model/parser/SpecificationParser.d.ts +8 -0
- package/dist/model/parser/SpecificationParser.js +5 -9
- package/dist/model/parser/ViewsParser.d.ts +36 -19
- package/dist/model/parser/ViewsParser.js +15 -11
- package/dist/model-change/changeElementStyle.d.ts +2 -2
- package/dist/model-change/changeElementStyle.js +2 -1
- package/dist/references/name-provider.js +8 -2
- package/dist/references/scope-computation.d.ts +1 -1
- package/dist/references/scope-computation.js +33 -3
- package/dist/references/scope-provider.d.ts +7 -8
- package/dist/references/scope-provider.js +59 -41
- package/dist/shared/NodeKindProvider.js +4 -2
- package/dist/test/testServices.d.ts +2 -0
- package/dist/test/testServices.js +4 -1
- package/dist/utils/elementRef.d.ts +1 -1
- package/dist/utils/elementRef.js +6 -1
- package/dist/utils/fqnRef.d.ts +3 -0
- package/dist/utils/fqnRef.js +15 -4
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +9 -0
- package/dist/utils/projectId.d.ts +2 -1
- package/dist/utils/projectId.js +11 -1
- package/dist/validation/_shared.js +2 -2
- package/dist/validation/deployment-checks.js +24 -10
- package/dist/validation/element-ref.d.ts +4 -0
- package/dist/validation/element-ref.js +12 -0
- package/dist/validation/element.d.ts +1 -1
- package/dist/validation/element.js +1 -1
- package/dist/validation/imports.d.ts +5 -0
- package/dist/validation/imports.js +30 -0
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +47 -45
- package/dist/validation/relation.d.ts +2 -2
- package/dist/validation/relation.js +24 -27
- package/dist/validation/specification.d.ts +9 -9
- package/dist/validation/specification.js +9 -9
- package/dist/validation/view-predicates/{element-with.d.ts → fqn-expr-with.d.ts} +1 -1
- package/dist/validation/view-predicates/fqn-expr-with.js +42 -0
- package/dist/validation/view-predicates/fqn-ref-expr.d.ts +4 -0
- package/dist/validation/view-predicates/fqn-ref-expr.js +53 -0
- package/dist/validation/view-predicates/incoming.d.ts +1 -1
- package/dist/validation/view-predicates/incoming.js +2 -2
- package/dist/validation/view-predicates/index.d.ts +6 -6
- package/dist/validation/view-predicates/index.js +6 -6
- package/dist/validation/view-predicates/outgoing.d.ts +1 -1
- package/dist/validation/view-predicates/outgoing.js +8 -4
- package/dist/validation/view-predicates/{expanded-element.d.ts → relation-expr.d.ts} +1 -1
- package/dist/validation/view-predicates/relation-expr.js +39 -0
- package/dist/validation/view-predicates/relation-with.d.ts +1 -1
- package/dist/validation/view-predicates/relation-with.js +8 -5
- package/dist/workspace/AstNodeDescriptionProvider.d.ts +1 -1
- package/dist/workspace/AstNodeDescriptionProvider.js +2 -3
- package/dist/workspace/IndexManager.d.ts +1 -1
- package/dist/workspace/IndexManager.js +5 -4
- package/dist/workspace/LangiumDocuments.d.ts +1 -1
- package/dist/workspace/LangiumDocuments.js +3 -5
- package/dist/workspace/ProjectsManager.d.ts +25 -7
- package/dist/workspace/ProjectsManager.js +76 -32
- package/dist/workspace/WorkspaceManager.d.ts +4 -5
- package/dist/workspace/WorkspaceManager.js +53 -20
- package/package.json +12 -10
- package/dist/validation/dynamic-view-rule.d.ts +0 -4
- package/dist/validation/dynamic-view-rule.js +0 -17
- package/dist/validation/view-predicates/element-with.js +0 -31
- package/dist/validation/view-predicates/expanded-element.js +0 -12
- package/dist/validation/view-predicates/expression-v2.d.ts +0 -5
- package/dist/validation/view-predicates/expression-v2.js +0 -83
package/dist/config/schema.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import * as v from 'valibot';
|
|
2
2
|
export declare const ProjectConfig: v.ObjectSchema<{
|
|
3
|
-
readonly name: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>, v.DescriptionAction<string, "Project name, must be unique in the workspace">]>;
|
|
4
|
-
readonly contactPerson: v.OptionalSchema<v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>, v.DescriptionAction<string, "A person who has been involved in creating or maintaining this project">]>, undefined>;
|
|
5
|
-
readonly exclude: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"node_modules
|
|
3
|
+
readonly name: v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.DescriptionAction<string, "Project name, must be unique in the workspace">]>;
|
|
4
|
+
readonly contactPerson: v.OptionalSchema<v.SchemaWithPipe<readonly [v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.NonEmptyAction<string, undefined>]>, v.DescriptionAction<string, "A person who has been involved in creating or maintaining this project">]>, undefined>;
|
|
5
|
+
readonly exclude: v.OptionalSchema<v.SchemaWithPipe<readonly [v.ArraySchema<v.StringSchema<undefined>, undefined>, v.DescriptionAction<string[], "List of file patterns to exclude from the project, default is [\"**/node_modules/**/*\"]">]>, undefined>;
|
|
6
6
|
}, undefined>;
|
|
7
7
|
export type ProjectConfig = v.InferOutput<typeof ProjectConfig>;
|
|
8
8
|
export declare function parseConfigJson(config: string): ProjectConfig;
|
package/dist/config/schema.js
CHANGED
|
@@ -1,22 +1,29 @@
|
|
|
1
1
|
import JSON5 from "json5";
|
|
2
2
|
import * as v from "valibot";
|
|
3
|
+
const nonEmptyString = v.pipe(v.string(), v.nonEmpty());
|
|
3
4
|
export const ProjectConfig = v.object({
|
|
4
5
|
name: v.pipe(
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
nonEmptyString,
|
|
7
|
+
// TODO: check if this is needed
|
|
8
|
+
// v.excludes('.', 'Project name cannot contain "."'),
|
|
7
9
|
v.description("Project name, must be unique in the workspace")
|
|
8
10
|
),
|
|
9
11
|
contactPerson: v.optional(
|
|
10
12
|
v.pipe(
|
|
11
|
-
|
|
12
|
-
v.nonEmpty(),
|
|
13
|
+
nonEmptyString,
|
|
13
14
|
v.description("A person who has been involved in creating or maintaining this project")
|
|
14
15
|
)
|
|
15
16
|
),
|
|
17
|
+
// imports: v.optional(
|
|
18
|
+
// v.pipe(
|
|
19
|
+
// v.record(v.string(), nonEmptyString),
|
|
20
|
+
// v.description('Imported projects'),
|
|
21
|
+
// ),
|
|
22
|
+
// ),
|
|
16
23
|
exclude: v.optional(
|
|
17
24
|
v.pipe(
|
|
18
25
|
v.array(v.string()),
|
|
19
|
-
v.description('List of file patterns to exclude from the project, default is ["node_modules"]')
|
|
26
|
+
v.description('List of file patterns to exclude from the project, default is ["**/node_modules/**/*"]')
|
|
20
27
|
)
|
|
21
28
|
)
|
|
22
29
|
});
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { FqnRef } from "@likec4/core";
|
|
1
2
|
import { AstUtils } from "langium";
|
|
2
3
|
import { ast } from "../ast.js";
|
|
3
4
|
import { logWarnError } from "../logger.js";
|
|
@@ -22,7 +23,8 @@ export class LikeC4DocumentationProvider {
|
|
|
22
23
|
if (ast.isDeployedInstance(node)) {
|
|
23
24
|
const doc = AstUtils.getDocument(node);
|
|
24
25
|
const instance = this.parser.forDocument(doc).parseDeployedInstance(node);
|
|
25
|
-
const
|
|
26
|
+
const [projectId, fqn] = FqnRef.isImportRef(instance.element) ? [instance.element.project, instance.element.model] : [doc.likec4ProjectId, instance.element.model];
|
|
27
|
+
const el = projectId ? this.locator.getParsedElement(fqn, projectId) : this.locator.getParsedElement(fqn);
|
|
26
28
|
const lines = [instance.id, `_instance of_ ${instance.element}`];
|
|
27
29
|
if (el) {
|
|
28
30
|
lines.push(" ", `**${el.title}**`);
|
|
@@ -25,12 +25,10 @@ export declare class LikeC4Formatter extends AbstractFormatter {
|
|
|
25
25
|
protected formatViewRuleGroup(node: AstNode): void;
|
|
26
26
|
protected formatViewRuleStyle(node: AstNode): void;
|
|
27
27
|
protected formatWhereExpression(node: AstNode): void;
|
|
28
|
-
protected formatWhereExpressionV2(node: AstNode): void;
|
|
29
28
|
protected formatWhereRelationExpression(node: AstNode): void;
|
|
30
29
|
protected formatWhereElementExpression(node: AstNode): void;
|
|
31
30
|
protected formatIncludeExcludeExpressions(node: AstNode): void;
|
|
32
31
|
protected formatRelationExpression(node: AstNode): void;
|
|
33
|
-
protected formatDeploymentViewRulePredicateExpressions(node: AstNode): void;
|
|
34
32
|
private findPredicateExpressionRoot;
|
|
35
33
|
private on;
|
|
36
34
|
}
|
|
@@ -27,9 +27,7 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
27
27
|
this.formatViewRuleGlobalStyle(node);
|
|
28
28
|
this.formatViewRuleGlobalPredicate(node);
|
|
29
29
|
this.formatIncludeExcludeExpressions(node);
|
|
30
|
-
this.formatDeploymentViewRulePredicateExpressions(node);
|
|
31
30
|
this.formatWhereExpression(node);
|
|
32
|
-
this.formatWhereExpressionV2(node);
|
|
33
31
|
this.formatWhereRelationExpression(node);
|
|
34
32
|
this.formatWhereElementExpression(node);
|
|
35
33
|
this.formatRelationExpression(node);
|
|
@@ -61,17 +59,21 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
61
59
|
});
|
|
62
60
|
}
|
|
63
61
|
formatRelation(node) {
|
|
64
|
-
this.on(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
f
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
62
|
+
this.on(
|
|
63
|
+
node,
|
|
64
|
+
(n) => ast.isRelation(n) || ast.isDeploymentRelation(n),
|
|
65
|
+
(n, f) => {
|
|
66
|
+
const sourceNodes = n?.source?.$cstNode ? [n?.source?.$cstNode] : [];
|
|
67
|
+
f.cst(sourceNodes).append(FormattingOptions.oneSpace);
|
|
68
|
+
f.keywords("]->").prepend(FormattingOptions.noSpace);
|
|
69
|
+
f.keywords("-[").append(FormattingOptions.noSpace);
|
|
70
|
+
f.nodes(...filter([
|
|
71
|
+
n.target,
|
|
72
|
+
n.tags
|
|
73
|
+
], isTruthy)).prepend(FormattingOptions.oneSpace);
|
|
74
|
+
f.properties("title", "technology").prepend(FormattingOptions.oneSpace);
|
|
75
|
+
}
|
|
76
|
+
);
|
|
75
77
|
this.on(node, ast.isDynamicViewStep, (n, f) => {
|
|
76
78
|
f.keywords("->", "<-").surround(FormattingOptions.oneSpace);
|
|
77
79
|
const kind = f.property("kind");
|
|
@@ -80,19 +82,11 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
80
82
|
f.keywords("-[").prepend(FormattingOptions.oneSpace).append(FormattingOptions.noSpace);
|
|
81
83
|
f.properties("title").prepend(FormattingOptions.oneSpace);
|
|
82
84
|
});
|
|
83
|
-
this.on(node, ast.isDirectedRelationExpression)?.property("target").prepend(FormattingOptions.oneSpace);
|
|
84
|
-
this.on(node, ast.isOutgoingRelationExpression, (n, f) => {
|
|
85
|
-
f.property("from").append(FormattingOptions.oneSpace);
|
|
86
|
-
f.keywords("]->").prepend(FormattingOptions.noSpace);
|
|
87
|
-
f.keywords("-[").append(FormattingOptions.noSpace);
|
|
88
|
-
});
|
|
89
|
-
this.on(node, ast.isIncomingRelationExpression)?.keywords("->").append(FormattingOptions.oneSpace);
|
|
90
|
-
this.on(node, ast.isInOutRelationExpression)?.keyword("->").prepend(FormattingOptions.oneSpace);
|
|
91
85
|
}
|
|
92
86
|
removeIndentFromTopLevelStatements(node) {
|
|
93
|
-
if (ast.
|
|
87
|
+
if (ast.isLikeC4Grammar(node.$container)) {
|
|
94
88
|
const formatter = this.getNodeFormatter(node);
|
|
95
|
-
formatter.keywords("specification", "model", "views", "likec4lib", "global", "deployments").prepend(FormattingOptions.noIndent);
|
|
89
|
+
formatter.keywords("specification", "model", "views", "likec4lib", "global", "deployments", "import").prepend(FormattingOptions.noIndent);
|
|
96
90
|
}
|
|
97
91
|
}
|
|
98
92
|
indentContentInBraces(node) {
|
|
@@ -222,8 +216,8 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
222
216
|
}
|
|
223
217
|
}
|
|
224
218
|
formatWithPredicate(node) {
|
|
225
|
-
|
|
226
|
-
|
|
219
|
+
if (ast.isFqnExprWith(node) || ast.isRelationExprWith(node)) {
|
|
220
|
+
const formatter = this.getNodeFormatter(node);
|
|
227
221
|
formatter.keyword("with").prepend(FormattingOptions.oneSpace);
|
|
228
222
|
}
|
|
229
223
|
}
|
|
@@ -271,17 +265,11 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
271
265
|
formatViewRuleStyle(node) {
|
|
272
266
|
this.on(node, ast.isViewRuleStyle)?.keyword("style").append(FormattingOptions.oneSpace);
|
|
273
267
|
this.on(node, ast.isDeploymentViewRuleStyle)?.keyword("style").append(FormattingOptions.oneSpace);
|
|
274
|
-
this.on(node, ast.
|
|
268
|
+
this.on(node, ast.isExpressions)?.keyword(",").prepend(FormattingOptions.noSpace).append(FormattingOptions.oneSpace);
|
|
275
269
|
this.on(node, ast.isFqnExpressions)?.keyword(",").prepend(FormattingOptions.noSpace).append(FormattingOptions.oneSpace);
|
|
276
270
|
}
|
|
277
271
|
formatWhereExpression(node) {
|
|
278
|
-
if (ast.
|
|
279
|
-
const formatter = this.getNodeFormatter(node);
|
|
280
|
-
formatter.keyword("where").append(FormattingOptions.oneSpace);
|
|
281
|
-
}
|
|
282
|
-
}
|
|
283
|
-
formatWhereExpressionV2(node) {
|
|
284
|
-
if (ast.isRelationPredicateOrWhereV2(node) || ast.isElementPredicateOrWhereV2(node)) {
|
|
272
|
+
if (ast.isRelationExprWhere(node) || ast.isFqnExprWhere(node)) {
|
|
285
273
|
const formatter = this.getNodeFormatter(node);
|
|
286
274
|
formatter.keyword("where").append(FormattingOptions.oneSpace);
|
|
287
275
|
}
|
|
@@ -313,13 +301,13 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
313
301
|
}
|
|
314
302
|
}
|
|
315
303
|
formatIncludeExcludeExpressions(node) {
|
|
316
|
-
if (ast.isDynamicViewRule(node) || ast.
|
|
304
|
+
if (ast.isDynamicViewRule(node) || ast.isViewRulePredicate(node) || ast.isDeploymentViewRulePredicate(node)) {
|
|
317
305
|
const formatter = this.getNodeFormatter(node);
|
|
318
306
|
if (!node.$cstNode || !utils.isMultiline(node.$cstNode)) {
|
|
319
307
|
formatter.keywords("include", "exclude").append(FormattingOptions.oneSpace);
|
|
320
308
|
}
|
|
321
309
|
}
|
|
322
|
-
if (ast.
|
|
310
|
+
if (ast.isExpressions(node)) {
|
|
323
311
|
const formatter = this.getNodeFormatter(node);
|
|
324
312
|
const parent = this.findPredicateExpressionRoot(node);
|
|
325
313
|
const isMultiline = parent?.$cstNode && utils.isMultiline(parent?.$cstNode);
|
|
@@ -347,27 +335,10 @@ export class LikeC4Formatter extends AbstractFormatter {
|
|
|
347
335
|
f.property("target").prepend(FormattingOptions.oneSpace);
|
|
348
336
|
});
|
|
349
337
|
}
|
|
350
|
-
formatDeploymentViewRulePredicateExpressions(node) {
|
|
351
|
-
if (ast.isDynamicViewRule(node) || ast.isIncludePredicate(node) || ast.isExcludePredicate(node) || ast.isDeploymentViewRulePredicate(node)) {
|
|
352
|
-
const formatter = this.getNodeFormatter(node);
|
|
353
|
-
if (!node.$cstNode || !utils.isMultiline(node.$cstNode)) {
|
|
354
|
-
formatter.keywords("include", "exclude").append(FormattingOptions.oneSpace);
|
|
355
|
-
}
|
|
356
|
-
}
|
|
357
|
-
if (ast.isDeploymentViewRulePredicateExpression(node)) {
|
|
358
|
-
const formatter = this.getNodeFormatter(node);
|
|
359
|
-
const parent = this.findPredicateExpressionRoot(node);
|
|
360
|
-
const isMultiline = parent?.$cstNode && utils.isMultiline(parent?.$cstNode);
|
|
361
|
-
if (isMultiline) {
|
|
362
|
-
formatter.property("value").prepend(FormattingOptions.indent);
|
|
363
|
-
}
|
|
364
|
-
formatter.keyword(",").prepend(FormattingOptions.noSpace).append(isMultiline ? FormattingOptions.newLine : FormattingOptions.oneSpace);
|
|
365
|
-
}
|
|
366
|
-
}
|
|
367
338
|
findPredicateExpressionRoot(node) {
|
|
368
339
|
let parent = node.$container;
|
|
369
340
|
while (true) {
|
|
370
|
-
if (!parent || ast.isDynamicViewRule(parent) || ast.
|
|
341
|
+
if (!parent || ast.isDynamicViewRule(parent) || ast.isViewRulePredicate(parent) || ast.isDeploymentViewRulePredicate(parent)) {
|
|
371
342
|
return parent;
|
|
372
343
|
}
|
|
373
344
|
parent = parent.$container;
|