@likec4/language-server 1.27.2 → 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
|
@@ -26,11 +26,11 @@ export class DefaultLikeC4LanguageServices {
|
|
|
26
26
|
entries(),
|
|
27
27
|
map(([projectId, docs]) => {
|
|
28
28
|
const id = projectId;
|
|
29
|
-
const { folder, config } = projectsManager.getProject(id);
|
|
29
|
+
const { folder: folder2, config: config2 } = projectsManager.getProject(id);
|
|
30
30
|
return {
|
|
31
31
|
id,
|
|
32
|
-
folder,
|
|
33
|
-
config,
|
|
32
|
+
folder: folder2,
|
|
33
|
+
config: config2,
|
|
34
34
|
documents: map(docs, prop("uri"))
|
|
35
35
|
};
|
|
36
36
|
})
|
|
@@ -38,12 +38,11 @@ export class DefaultLikeC4LanguageServices {
|
|
|
38
38
|
if (hasAtLeast(projectsWithDocs, 1)) {
|
|
39
39
|
return projectsWithDocs;
|
|
40
40
|
}
|
|
41
|
+
const { folder, config } = projectsManager.getProject(ProjectsManager.DefaultProjectId);
|
|
41
42
|
return [{
|
|
42
43
|
id: ProjectsManager.DefaultProjectId,
|
|
43
|
-
folder
|
|
44
|
-
config
|
|
45
|
-
name: "default"
|
|
46
|
-
},
|
|
44
|
+
folder,
|
|
45
|
+
config,
|
|
47
46
|
documents: null
|
|
48
47
|
}];
|
|
49
48
|
}
|
package/dist/ast.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import type * as c4 from '@likec4/core';
|
|
2
|
+
import { MultiMap } from '@likec4/core';
|
|
2
3
|
import type { AstNode, AstNodeDescription, DiagnosticInfo, LangiumDocument } from 'langium';
|
|
3
|
-
import type { ConditionalPick, ValueOf, Writable } from 'type-fest';
|
|
4
|
+
import type { ConditionalPick, MergeExclusive, Simplify, ValueOf, Writable } from 'type-fest';
|
|
4
5
|
import type { Diagnostic } from 'vscode-languageserver-types';
|
|
5
6
|
import type { LikeC4Grammar } from './generated/ast';
|
|
6
7
|
import * as ast from './generated/ast';
|
|
7
8
|
import type { IsValidFn } from './validation';
|
|
8
9
|
export { ast };
|
|
9
|
-
declare const idattr: unique symbol;
|
|
10
10
|
declare module 'langium' {
|
|
11
11
|
interface LangiumDocument {
|
|
12
12
|
likec4ProjectId?: c4.ProjectId;
|
|
@@ -15,6 +15,7 @@ declare module 'langium' {
|
|
|
15
15
|
likec4ProjectId?: c4.ProjectId;
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
|
+
declare const idattr: unique symbol;
|
|
18
19
|
declare module './generated/ast' {
|
|
19
20
|
interface Element {
|
|
20
21
|
[idattr]?: c4.Fqn | undefined;
|
|
@@ -35,7 +36,7 @@ declare module './generated/ast' {
|
|
|
35
36
|
[idattr]?: c4.Fqn | undefined;
|
|
36
37
|
}
|
|
37
38
|
}
|
|
38
|
-
type ParsedElementStyle = {
|
|
39
|
+
export type ParsedElementStyle = {
|
|
39
40
|
shape?: c4.ElementShape;
|
|
40
41
|
icon?: c4.IconUrl;
|
|
41
42
|
color?: c4.Color;
|
|
@@ -92,8 +93,8 @@ export interface ParsedAstExtend {
|
|
|
92
93
|
export interface ParsedAstRelation {
|
|
93
94
|
id: c4.RelationId;
|
|
94
95
|
astPath: string;
|
|
95
|
-
source: c4.
|
|
96
|
-
target: c4.
|
|
96
|
+
source: c4.FqnRef.ModelRef | c4.FqnRef.ImportRef;
|
|
97
|
+
target: c4.FqnRef.ModelRef | c4.FqnRef.ImportRef;
|
|
97
98
|
kind?: c4.RelationshipKind;
|
|
98
99
|
tags?: c4.NonEmptyArray<c4.Tag>;
|
|
99
100
|
title: string;
|
|
@@ -109,10 +110,12 @@ export interface ParsedAstRelation {
|
|
|
109
110
|
[key: string]: string;
|
|
110
111
|
};
|
|
111
112
|
}
|
|
112
|
-
export type ParsedAstDeployment =
|
|
113
|
+
export type ParsedAstDeployment = Simplify<MergeExclusive<ParsedAstDeployment.Node, ParsedAstDeployment.Instance>>;
|
|
113
114
|
export declare namespace ParsedAstDeployment {
|
|
114
115
|
type Node = c4.DeploymentNode;
|
|
115
|
-
type Instance = c4.DeployedInstance
|
|
116
|
+
type Instance = Omit<c4.DeployedInstance, 'element'> & {
|
|
117
|
+
readonly element: c4.FqnRef.ModelRef | c4.FqnRef.ImportRef;
|
|
118
|
+
};
|
|
116
119
|
}
|
|
117
120
|
export type ParsedAstDeploymentRelation = c4.DeploymentRelation & {
|
|
118
121
|
astPath: string;
|
|
@@ -163,6 +166,7 @@ export declare const ElementOps: {
|
|
|
163
166
|
readId(node: ast.Element | ast.DeploymentElement): any;
|
|
164
167
|
};
|
|
165
168
|
export interface AstNodeDescriptionWithFqn extends AstNodeDescription {
|
|
169
|
+
likec4ProjectId: c4.ProjectId;
|
|
166
170
|
id: c4.Fqn;
|
|
167
171
|
}
|
|
168
172
|
export type LikeC4AstNode = ValueOf<ConditionalPick<ast.LikeC4AstType, AstNode>>;
|
|
@@ -178,6 +182,7 @@ export interface LikeC4DocumentProps {
|
|
|
178
182
|
c4Views?: ParsedAstView[];
|
|
179
183
|
c4Deployments?: ParsedAstDeployment[];
|
|
180
184
|
c4DeploymentRelations?: ParsedAstDeploymentRelation[];
|
|
185
|
+
c4Imports?: MultiMap<c4.ProjectId, c4.Fqn, Set<c4.Fqn>>;
|
|
181
186
|
}
|
|
182
187
|
type LikeC4GrammarDocument = Omit<LangiumDocument<LikeC4Grammar>, 'diagnostics'>;
|
|
183
188
|
export interface LikeC4LangiumDocument extends LikeC4GrammarDocument, LikeC4DocumentProps {
|
|
@@ -192,7 +197,6 @@ export declare function parseAstOpacityProperty({ value }: ast.OpacityProperty):
|
|
|
192
197
|
export declare function parseAstSizeValue({ value }: {
|
|
193
198
|
value: ast.SizeValue;
|
|
194
199
|
}): 'xs' | 'sm' | 'md' | 'lg' | 'xl';
|
|
195
|
-
export declare function toElementStyle(props: Array<ast.StyleProperty> | undefined, isValid: IsValidFn): ParsedElementStyle;
|
|
196
200
|
export declare function toRelationshipStyle(props: ast.RelationshipStyleProperty[] | undefined, isValid: IsValidFn): {
|
|
197
201
|
color?: c4.Color;
|
|
198
202
|
line?: c4.RelationshipLineType;
|
|
@@ -208,4 +212,7 @@ export declare function toRelationshipStyleExcludeDefaults(props: ast.Specificat
|
|
|
208
212
|
export declare function toColor(astNode: ast.ColorProperty): c4.Color | undefined;
|
|
209
213
|
export declare function toAutoLayout(rule: ast.ViewRuleAutoLayout): c4.ViewRuleAutoLayout;
|
|
210
214
|
export declare function toAstViewLayoutDirection(c4: c4.ViewRuleAutoLayout['direction']): ast.ViewLayoutDirection;
|
|
211
|
-
export declare function
|
|
215
|
+
export declare function getViewRulePredicateContainer<T extends AstNode>(el: T): ast.ViewRulePredicate | ast.DeploymentViewRulePredicate | ast.DynamicViewIncludePredicate | undefined;
|
|
216
|
+
export declare function isFqnRefInsideGlobals(astNode: AstNode): boolean;
|
|
217
|
+
export declare function isFqnRefInsideModel(astNode: AstNode): boolean;
|
|
218
|
+
export declare function isFqnRefInsideDeployment(astNode: AstNode): boolean;
|
package/dist/ast.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor, nonexhaustive } from "@likec4/core";
|
|
2
|
-
import { DocumentState } from "langium";
|
|
3
|
-
import { clamp,
|
|
2
|
+
import { AstUtils, DocumentState } from "langium";
|
|
3
|
+
import { clamp, isNullish, isTruthy } from "remeda";
|
|
4
4
|
import * as ast from "./generated/ast.js";
|
|
5
5
|
import { LikeC4LanguageMetaData } from "./generated/module.js";
|
|
6
6
|
export { ast };
|
|
@@ -31,7 +31,7 @@ export function isLikeC4LangiumDocument(doc) {
|
|
|
31
31
|
return doc.textDocument.languageId === LikeC4LanguageMetaData.languageId;
|
|
32
32
|
}
|
|
33
33
|
export function isParsedLikeC4LangiumDocument(doc) {
|
|
34
|
-
return isLikeC4LangiumDocument(doc) && doc.state == DocumentState.Validated && !!doc.c4Specification && !!doc.c4Elements && !!doc.c4ExtendElements && !!doc.c4ExtendDeployments && !!doc.c4Relations && !!doc.c4Views && !!doc.c4Deployments && !!doc.c4DeploymentRelations;
|
|
34
|
+
return isLikeC4LangiumDocument(doc) && doc.state == DocumentState.Validated && !!doc.c4Specification && !!doc.c4Elements && !!doc.c4ExtendElements && !!doc.c4ExtendDeployments && !!doc.c4Relations && !!doc.c4Views && !!doc.c4Deployments && !!doc.c4DeploymentRelations && !!doc.c4Imports;
|
|
35
35
|
}
|
|
36
36
|
export function parseAstOpacityProperty({ value }) {
|
|
37
37
|
const opacity = parseFloat(value);
|
|
@@ -59,74 +59,6 @@ export function parseAstSizeValue({ value }) {
|
|
|
59
59
|
nonexhaustive(value);
|
|
60
60
|
}
|
|
61
61
|
}
|
|
62
|
-
export function toElementStyle(props, isValid) {
|
|
63
|
-
const result = {};
|
|
64
|
-
if (!props || props.length === 0) {
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
for (const prop of props) {
|
|
68
|
-
if (!isValid(prop)) {
|
|
69
|
-
continue;
|
|
70
|
-
}
|
|
71
|
-
switch (true) {
|
|
72
|
-
case ast.isBorderProperty(prop): {
|
|
73
|
-
if (isTruthy(prop.value)) {
|
|
74
|
-
result.border = prop.value;
|
|
75
|
-
}
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
case ast.isColorProperty(prop): {
|
|
79
|
-
const color = toColor(prop);
|
|
80
|
-
if (isTruthy(color)) {
|
|
81
|
-
result.color = color;
|
|
82
|
-
}
|
|
83
|
-
break;
|
|
84
|
-
}
|
|
85
|
-
case ast.isShapeProperty(prop): {
|
|
86
|
-
if (isTruthy(prop.value)) {
|
|
87
|
-
result.shape = prop.value;
|
|
88
|
-
}
|
|
89
|
-
break;
|
|
90
|
-
}
|
|
91
|
-
case ast.isIconProperty(prop): {
|
|
92
|
-
const icon = prop.libicon?.ref?.name ?? prop.value;
|
|
93
|
-
if (isTruthy(icon)) {
|
|
94
|
-
result.icon = icon;
|
|
95
|
-
}
|
|
96
|
-
break;
|
|
97
|
-
}
|
|
98
|
-
case ast.isOpacityProperty(prop): {
|
|
99
|
-
result.opacity = parseAstOpacityProperty(prop);
|
|
100
|
-
break;
|
|
101
|
-
}
|
|
102
|
-
case ast.isMultipleProperty(prop): {
|
|
103
|
-
result.multiple = isBoolean(prop.value) ? prop.value : false;
|
|
104
|
-
break;
|
|
105
|
-
}
|
|
106
|
-
case ast.isShapeSizeProperty(prop): {
|
|
107
|
-
if (isTruthy(prop.value)) {
|
|
108
|
-
result.size = parseAstSizeValue(prop);
|
|
109
|
-
}
|
|
110
|
-
break;
|
|
111
|
-
}
|
|
112
|
-
case ast.isPaddingSizeProperty(prop): {
|
|
113
|
-
if (isTruthy(prop.value)) {
|
|
114
|
-
result.padding = parseAstSizeValue(prop);
|
|
115
|
-
}
|
|
116
|
-
break;
|
|
117
|
-
}
|
|
118
|
-
case ast.isTextSizeProperty(prop): {
|
|
119
|
-
if (isTruthy(prop.value)) {
|
|
120
|
-
result.textSize = parseAstSizeValue(prop);
|
|
121
|
-
}
|
|
122
|
-
break;
|
|
123
|
-
}
|
|
124
|
-
default:
|
|
125
|
-
nonexhaustive(prop);
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return result;
|
|
129
|
-
}
|
|
130
62
|
export function toRelationshipStyle(props, isValid) {
|
|
131
63
|
const result = {};
|
|
132
64
|
if (!props || props.length === 0) {
|
|
@@ -231,15 +163,62 @@ export function toAstViewLayoutDirection(c4) {
|
|
|
231
163
|
nonexhaustive(c4);
|
|
232
164
|
}
|
|
233
165
|
}
|
|
234
|
-
export function
|
|
235
|
-
|
|
236
|
-
|
|
166
|
+
export function getViewRulePredicateContainer(el) {
|
|
167
|
+
return AstUtils.getContainerOfType(
|
|
168
|
+
el,
|
|
169
|
+
(n) => {
|
|
170
|
+
return ast.isViewRulePredicate(n) || ast.isDeploymentViewRulePredicate(n) || ast.isDynamicViewIncludePredicate(n);
|
|
171
|
+
}
|
|
172
|
+
);
|
|
173
|
+
}
|
|
174
|
+
const _isModel = (astNode) => {
|
|
175
|
+
return ast.isModel(astNode) || ast.isElementBody(astNode) || ast.isExtendElementBody(astNode) || ast.isElementViewBody(astNode) || ast.isDynamicViewBody(astNode) || ast.isElementRef(astNode);
|
|
176
|
+
};
|
|
177
|
+
const _isDeployment = (astNode) => {
|
|
178
|
+
return ast.isModelDeployments(astNode) || ast.isDeploymentViewBody(astNode) || ast.isDeploymentNodeBody(astNode) || ast.isExtendDeploymentBody(astNode) || ast.isDeployedInstanceBody(astNode);
|
|
179
|
+
};
|
|
180
|
+
export function isFqnRefInsideGlobals(astNode) {
|
|
181
|
+
while (true) {
|
|
182
|
+
if (_isDeployment(astNode) || _isModel(astNode)) {
|
|
183
|
+
return false;
|
|
184
|
+
}
|
|
185
|
+
if (ast.isGlobals(astNode) || ast.isModelViews(astNode)) {
|
|
186
|
+
return true;
|
|
187
|
+
}
|
|
188
|
+
if (astNode.$container) {
|
|
189
|
+
astNode = astNode.$container;
|
|
190
|
+
} else {
|
|
191
|
+
return false;
|
|
192
|
+
}
|
|
237
193
|
}
|
|
238
|
-
|
|
239
|
-
|
|
194
|
+
}
|
|
195
|
+
export function isFqnRefInsideModel(astNode) {
|
|
196
|
+
while (true) {
|
|
197
|
+
if (_isDeployment(astNode)) {
|
|
198
|
+
return false;
|
|
199
|
+
}
|
|
200
|
+
if (_isModel(astNode)) {
|
|
201
|
+
return true;
|
|
202
|
+
}
|
|
203
|
+
if (astNode.$container) {
|
|
204
|
+
astNode = astNode.$container;
|
|
205
|
+
} else {
|
|
206
|
+
return false;
|
|
207
|
+
}
|
|
240
208
|
}
|
|
241
|
-
|
|
242
|
-
|
|
209
|
+
}
|
|
210
|
+
export function isFqnRefInsideDeployment(astNode) {
|
|
211
|
+
while (true) {
|
|
212
|
+
if (_isModel(astNode)) {
|
|
213
|
+
return false;
|
|
214
|
+
}
|
|
215
|
+
if (_isDeployment(astNode)) {
|
|
216
|
+
return true;
|
|
217
|
+
}
|
|
218
|
+
if (astNode.$container) {
|
|
219
|
+
astNode = astNode.$container;
|
|
220
|
+
} else {
|
|
221
|
+
return false;
|
|
222
|
+
}
|
|
243
223
|
}
|
|
244
|
-
nonexhaustive(predicate);
|
|
245
224
|
}
|