@likec4/language-server 1.40.0 → 1.42.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/browser/package.json +4 -0
- package/browser-worker/package.json +4 -0
- package/dist/LikeC4LanguageServices.d.ts +1 -1
- package/dist/LikeC4LanguageServices.mjs +3 -2
- package/dist/Rpc.mjs +30 -24
- package/dist/ast.d.ts +4 -9
- package/dist/ast.mjs +0 -10
- package/dist/bundled.mjs +4158 -3687
- package/dist/documentation/documentation-provider.mjs +1 -1
- package/dist/filesystem/FileSystemWatcher.d.ts +2 -2
- package/dist/filesystem/index.d.ts +1 -1
- package/dist/formatting/LikeC4Formatter.mjs +42 -10
- package/dist/formatting/utils.d.ts +3 -3
- package/dist/formatting/utils.mjs +1 -1
- package/dist/generated/ast.d.ts +40 -19
- package/dist/generated/ast.mjs +71 -26
- package/dist/generated/grammar.mjs +1 -1
- package/dist/logger.d.ts +1 -1
- package/dist/logger.mjs +3 -0
- package/dist/lsp/CompletionProvider.mjs +1 -1
- package/dist/lsp/DocumentLinkProvider.d.ts +1 -1
- package/dist/lsp/DocumentLinkProvider.mjs +1 -1
- package/dist/lsp/DocumentSymbolProvider.mjs +1 -1
- package/dist/lsp/HoverProvider.mjs +14 -2
- package/dist/mcp/NoopLikeC4MCPServer.d.ts +1 -1
- package/dist/mcp/NoopLikeC4MCPServer.mjs +1 -1
- package/dist/mcp/server/StdioLikeC4MCPServer.mjs +4 -1
- package/dist/mcp/server/StreamableLikeC4MCPServer.mjs +3 -3
- package/dist/mcp/server/WithMCPServer.mjs +2 -2
- package/dist/mcp/tools/_common.mjs +2 -2
- package/dist/model/builder/MergedSpecification.d.ts +3 -3
- package/dist/model/builder/MergedSpecification.mjs +37 -59
- package/dist/model/builder/buildModel.mjs +14 -17
- package/dist/model/model-builder.d.ts +1 -1
- package/dist/model/model-builder.mjs +12 -9
- package/dist/model/model-locator.d.ts +5 -0
- package/dist/model/model-locator.mjs +40 -3
- package/dist/model/model-parser-where.mjs +1 -2
- package/dist/model/model-parser.d.ts +91 -47
- package/dist/model/parser/Base.d.ts +13 -7
- package/dist/model/parser/Base.mjs +32 -21
- package/dist/model/parser/DeploymentModelParser.d.ts +9 -5
- package/dist/model/parser/DeploymentModelParser.mjs +49 -47
- package/dist/model/parser/DeploymentViewParser.d.ts +9 -5
- package/dist/model/parser/DeploymentViewParser.mjs +1 -2
- package/dist/model/parser/FqnRefParser.d.ts +12 -6
- package/dist/model/parser/FqnRefParser.mjs +28 -15
- package/dist/model/parser/GlobalsParser.d.ts +16 -7
- package/dist/model/parser/GlobalsParser.mjs +5 -3
- package/dist/model/parser/ImportsParser.d.ts +8 -5
- package/dist/model/parser/ImportsParser.mjs +4 -2
- package/dist/model/parser/ModelParser.d.ts +9 -5
- package/dist/model/parser/ModelParser.mjs +42 -42
- package/dist/model/parser/PredicatesParser.d.ts +9 -5
- package/dist/model/parser/SpecificationParser.d.ts +8 -5
- package/dist/model/parser/SpecificationParser.mjs +17 -23
- package/dist/model/parser/ValueConverter.mjs +1 -1
- package/dist/model/parser/ViewsParser.d.ts +20 -7
- package/dist/model/parser/ViewsParser.mjs +125 -35
- package/dist/model-change/ModelChanges.d.ts +1 -1
- package/dist/module.mjs +3 -2
- package/dist/protocol.d.ts +28 -4
- package/dist/references/scope-computation.mjs +2 -3
- package/dist/references/scope-provider.d.ts +2 -2
- package/dist/references/scope-provider.mjs +8 -15
- package/dist/test/testServices.d.ts +2 -0
- package/dist/test/testServices.mjs +32 -35
- package/dist/utils/disposable.mjs +2 -2
- package/dist/utils/index.mjs +1 -1
- package/dist/validation/_shared.d.ts +1 -1
- package/dist/validation/deployment-checks.d.ts +1 -1
- package/dist/validation/deployment-checks.mjs +4 -1
- package/dist/validation/dynamic-view.d.ts +3 -2
- package/dist/validation/dynamic-view.mjs +21 -2
- package/dist/validation/element-ref.d.ts +2 -2
- package/dist/validation/element-ref.mjs +1 -1
- package/dist/validation/imports.d.ts +0 -1
- package/dist/validation/imports.mjs +0 -5
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.mjs +19 -13
- package/dist/validation/view-predicates/relation-with.d.ts +1 -1
- package/dist/validation/view.d.ts +1 -1
- package/dist/view-utils/index.d.ts +0 -1
- package/dist/view-utils/index.mjs +0 -1
- package/dist/views/likec4-views.d.ts +6 -0
- package/dist/views/likec4-views.mjs +31 -18
- package/dist/workspace/ProjectsManager.d.ts +23 -31
- package/dist/workspace/ProjectsManager.mjs +78 -89
- package/dist/workspace/WorkspaceManager.mjs +1 -1
- package/likec4lib/package.json +4 -0
- package/package.json +25 -29
- package/protocol/package.json +4 -0
- package/dist/view-utils/resolve-relative-paths.d.ts +0 -2
- package/dist/view-utils/resolve-relative-paths.mjs +0 -78
|
@@ -70,10 +70,10 @@ export interface LikeC4LanguageServices {
|
|
|
70
70
|
*/
|
|
71
71
|
export declare class DefaultLikeC4LanguageServices implements LikeC4LanguageServices {
|
|
72
72
|
private services;
|
|
73
|
-
readonly views: LikeC4Views;
|
|
74
73
|
readonly builder: LikeC4ModelBuilder;
|
|
75
74
|
readonly projectsManager: ProjectsManager;
|
|
76
75
|
constructor(services: LikeC4Services);
|
|
76
|
+
get views(): LikeC4Views;
|
|
77
77
|
get workspaceUri(): URI;
|
|
78
78
|
projects(): NonEmptyArray<{
|
|
79
79
|
id: ProjectId;
|
|
@@ -13,13 +13,14 @@ const logger = mainLogger.getChild("LanguageServices");
|
|
|
13
13
|
export class DefaultLikeC4LanguageServices {
|
|
14
14
|
constructor(services) {
|
|
15
15
|
this.services = services;
|
|
16
|
-
this.views = services.likec4.Views;
|
|
17
16
|
this.builder = services.likec4.ModelBuilder;
|
|
18
17
|
this.projectsManager = services.shared.workspace.ProjectsManager;
|
|
19
18
|
}
|
|
20
|
-
views;
|
|
21
19
|
builder;
|
|
22
20
|
projectsManager;
|
|
21
|
+
get views() {
|
|
22
|
+
return this.services.likec4.Views;
|
|
23
|
+
}
|
|
23
24
|
get workspaceUri() {
|
|
24
25
|
return this.services.shared.workspace.WorkspaceManager.workspaceUri;
|
|
25
26
|
}
|
package/dist/Rpc.mjs
CHANGED
|
@@ -2,6 +2,7 @@ import { filter, flatMap, funnel, indexBy, keys, map, mapValues, pipe, sort } fr
|
|
|
2
2
|
import { logger as rootLogger } from "./logger.mjs";
|
|
3
3
|
import { serializableLikeC4ProjectConfig } from "@likec4/config";
|
|
4
4
|
import {
|
|
5
|
+
invariant,
|
|
5
6
|
nonexhaustive
|
|
6
7
|
} from "@likec4/core";
|
|
7
8
|
import { LikeC4Model } from "@likec4/core/model";
|
|
@@ -33,17 +34,14 @@ export class Rpc extends ADisposable {
|
|
|
33
34
|
this.services = services;
|
|
34
35
|
}
|
|
35
36
|
init() {
|
|
36
|
-
const modelBuilder = this.services.likec4.ModelBuilder;
|
|
37
|
-
const modelLocator = this.services.likec4.ModelLocator;
|
|
38
|
-
const modelEditor = this.services.likec4.ModelChanges;
|
|
39
|
-
const views = this.services.likec4.Views;
|
|
40
37
|
const connection = this.services.shared.lsp.Connection;
|
|
41
|
-
const projects = this.services.shared.workspace.ProjectsManager;
|
|
42
38
|
if (!connection) {
|
|
43
39
|
logger.info(`[ServerRpc] no connection, not initializing`);
|
|
44
40
|
return;
|
|
45
41
|
}
|
|
46
42
|
logger.info(`[ServerRpc] init`);
|
|
43
|
+
const likec4Services = this.services.likec4;
|
|
44
|
+
const projects = this.services.shared.workspace.ProjectsManager;
|
|
47
45
|
const LangiumDocuments = this.services.shared.workspace.LangiumDocuments;
|
|
48
46
|
const DocumentBuilder = this.services.shared.workspace.DocumentBuilder;
|
|
49
47
|
const notifyModelParsed = funnel(
|
|
@@ -63,7 +61,7 @@ export class Rpc extends ADisposable {
|
|
|
63
61
|
);
|
|
64
62
|
let isFirstBuild = true;
|
|
65
63
|
this.onDispose(
|
|
66
|
-
|
|
64
|
+
likec4Services.ModelBuilder.onModelParsed(() => notifyModelParsed.call()),
|
|
67
65
|
connection.onRequest(FetchComputedModel.req, async ({ projectId, cleanCaches }, cancelToken) => {
|
|
68
66
|
logger.debug`received request ${"fetchComputedModel"} for project ${projectId}`;
|
|
69
67
|
if (cleanCaches) {
|
|
@@ -71,22 +69,22 @@ export class Rpc extends ADisposable {
|
|
|
71
69
|
const uris = docs.toArray().map((d) => d.uri);
|
|
72
70
|
await DocumentBuilder.update(uris, [], cancelToken);
|
|
73
71
|
}
|
|
74
|
-
const likec4model = await
|
|
72
|
+
const likec4model = await likec4Services.ModelBuilder.buildLikeC4Model(projectId, cancelToken);
|
|
75
73
|
if (likec4model !== LikeC4Model.EMPTY) {
|
|
76
74
|
return { model: likec4model.$model };
|
|
77
75
|
}
|
|
78
76
|
return { model: null };
|
|
79
77
|
}),
|
|
80
78
|
connection.onRequest(ComputeView.req, async ({ viewId, projectId }, cancelToken) => {
|
|
81
|
-
const view = await
|
|
79
|
+
const view = await likec4Services.ModelBuilder.computeView(viewId, projectId, cancelToken);
|
|
82
80
|
return { view };
|
|
83
81
|
}),
|
|
84
82
|
connection.onRequest(FetchLayoutedModel.req, async ({ projectId }, cancelToken) => {
|
|
85
|
-
const model = await
|
|
83
|
+
const model = await likec4Services.ModelBuilder.parseModel(projectId, cancelToken);
|
|
86
84
|
if (model === null) {
|
|
87
85
|
return { model: null };
|
|
88
86
|
}
|
|
89
|
-
const diagrams = await
|
|
87
|
+
const diagrams = await likec4Services.Views.diagrams(projectId, cancelToken);
|
|
90
88
|
return {
|
|
91
89
|
model: {
|
|
92
90
|
...model.$data,
|
|
@@ -97,11 +95,11 @@ export class Rpc extends ADisposable {
|
|
|
97
95
|
}),
|
|
98
96
|
connection.onRequest(LayoutView.req, async ({ viewId, projectId }, cancelToken) => {
|
|
99
97
|
logger.debug`received request ${"layoutView"} of ${viewId} from project ${projectId}`;
|
|
100
|
-
const result = await
|
|
98
|
+
const result = await likec4Services.Views.layoutView(viewId, projectId, cancelToken);
|
|
101
99
|
return { result };
|
|
102
100
|
}),
|
|
103
101
|
connection.onRequest(ValidateLayout.Req, async ({ projectId }, cancelToken) => {
|
|
104
|
-
const layouts = await
|
|
102
|
+
const layouts = await likec4Services.Views.layoutAllViews(projectId, cancelToken);
|
|
105
103
|
const result = reportLayoutDrift(layouts.map((l) => l.diagram));
|
|
106
104
|
return { result };
|
|
107
105
|
}),
|
|
@@ -122,9 +120,9 @@ export class Rpc extends ADisposable {
|
|
|
122
120
|
})
|
|
123
121
|
};
|
|
124
122
|
}),
|
|
125
|
-
connection.onRequest(ReloadProjects.req, async (
|
|
123
|
+
connection.onRequest(ReloadProjects.req, async () => {
|
|
126
124
|
logger.debug`received request ${"ReloadProjects"}`;
|
|
127
|
-
await projects.reloadProjects(
|
|
125
|
+
await projects.reloadProjects();
|
|
128
126
|
return;
|
|
129
127
|
}),
|
|
130
128
|
connection.onRequest(RegisterProject.req, async (params) => {
|
|
@@ -135,7 +133,7 @@ export class Rpc extends ADisposable {
|
|
|
135
133
|
connection.onRequest(FetchViewsFromAllProjects.req, async (cancelToken) => {
|
|
136
134
|
logger.debug`received request ${"FetchViewsFromAllProjects"}`;
|
|
137
135
|
const promises = projects.all.map(async (projectId) => {
|
|
138
|
-
const computedViews = await
|
|
136
|
+
const computedViews = await likec4Services.Views.computedViews(projectId, cancelToken);
|
|
139
137
|
return pipe(
|
|
140
138
|
computedViews,
|
|
141
139
|
map((v) => ({
|
|
@@ -196,25 +194,31 @@ export class Rpc extends ADisposable {
|
|
|
196
194
|
connection.onRequest(Locate.Req, (params) => {
|
|
197
195
|
switch (true) {
|
|
198
196
|
case "element" in params:
|
|
199
|
-
return
|
|
197
|
+
return likec4Services.ModelLocator.locateElement(params.element, params.projectId);
|
|
200
198
|
case "relation" in params:
|
|
201
|
-
return
|
|
199
|
+
return likec4Services.ModelLocator.locateRelation(params.relation, params.projectId);
|
|
200
|
+
case "astPath" in params:
|
|
201
|
+
return likec4Services.ModelLocator.locateDynamicViewStep({
|
|
202
|
+
view: params.view,
|
|
203
|
+
astPath: params.astPath,
|
|
204
|
+
projectId: params.projectId
|
|
205
|
+
});
|
|
202
206
|
case "view" in params:
|
|
203
|
-
return
|
|
207
|
+
return likec4Services.ModelLocator.locateView(params.view, params.projectId);
|
|
204
208
|
case "deployment" in params:
|
|
205
|
-
return
|
|
209
|
+
return likec4Services.ModelLocator.locateDeploymentElement(params.deployment, params.projectId);
|
|
206
210
|
default:
|
|
207
211
|
nonexhaustive(params);
|
|
208
212
|
}
|
|
209
213
|
}),
|
|
210
214
|
connection.onRequest(ChangeView.Req, async (request, _cancelToken) => {
|
|
211
215
|
logger.debug`received request ${"changeView"} of ${request.viewId} from project ${request.projectId}`;
|
|
212
|
-
return await
|
|
216
|
+
return await likec4Services.ModelChanges.applyChange(request);
|
|
213
217
|
}),
|
|
214
218
|
connection.onRequest(FetchTelemetryMetrics.req, async (cancelToken) => {
|
|
215
219
|
const projectsIds = [...projects.all];
|
|
216
220
|
const promises = projectsIds.map(async (projectId) => {
|
|
217
|
-
const model = await
|
|
221
|
+
const model = await likec4Services.ModelBuilder.buildLikeC4Model(projectId, cancelToken);
|
|
218
222
|
if (model === LikeC4Model.EMPTY) {
|
|
219
223
|
return Promise.reject(new Error(`Model is empty`));
|
|
220
224
|
}
|
|
@@ -251,7 +255,7 @@ export class Rpc extends ADisposable {
|
|
|
251
255
|
};
|
|
252
256
|
}),
|
|
253
257
|
connection.onRequest(GetDocumentTags.req, async ({ documentUri }, cancelToken) => {
|
|
254
|
-
const tags = await
|
|
258
|
+
const tags = await likec4Services.ModelLocator.locateDocumentTags(URI.parse(documentUri), cancelToken);
|
|
255
259
|
return {
|
|
256
260
|
tags
|
|
257
261
|
};
|
|
@@ -265,12 +269,14 @@ export class Rpc extends ADisposable {
|
|
|
265
269
|
diagrams,
|
|
266
270
|
filter((d) => !!d.hasLayoutDrift),
|
|
267
271
|
map((d) => {
|
|
272
|
+
const loc = likec4Services.ModelLocator.locateView(d.id);
|
|
273
|
+
invariant(loc, `View ${d.id} not found`);
|
|
268
274
|
return {
|
|
269
|
-
uri:
|
|
275
|
+
uri: loc.uri,
|
|
270
276
|
viewId: d.id,
|
|
271
277
|
severity: DiagnosticSeverity.Warning,
|
|
272
278
|
message: `Layout drift detected for view '${d.id}'`,
|
|
273
|
-
range:
|
|
279
|
+
range: loc.range
|
|
274
280
|
};
|
|
275
281
|
})
|
|
276
282
|
);
|
package/dist/ast.d.ts
CHANGED
|
@@ -71,6 +71,7 @@ export interface ParsedAstElement {
|
|
|
71
71
|
astPath: string;
|
|
72
72
|
kind: c4.ElementKind;
|
|
73
73
|
title: string;
|
|
74
|
+
summary?: c4.MarkdownOrString;
|
|
74
75
|
description?: c4.MarkdownOrString;
|
|
75
76
|
technology?: string;
|
|
76
77
|
tags?: c4.NonEmptyArray<c4.Tag>;
|
|
@@ -83,8 +84,8 @@ export interface ParsedAstElement {
|
|
|
83
84
|
export interface ParsedAstExtend {
|
|
84
85
|
id: c4.Fqn;
|
|
85
86
|
astPath: string;
|
|
86
|
-
tags
|
|
87
|
-
links
|
|
87
|
+
tags: c4.NonEmptyArray<c4.Tag> | null;
|
|
88
|
+
links: c4.NonEmptyArray<c4.Link> | null;
|
|
88
89
|
metadata?: {
|
|
89
90
|
[key: string]: string;
|
|
90
91
|
};
|
|
@@ -139,7 +140,7 @@ export interface ParsedAstDynamicView {
|
|
|
139
140
|
description: c4.MarkdownOrString | null;
|
|
140
141
|
tags: c4.NonEmptyArray<c4.Tag> | null;
|
|
141
142
|
links: c4.NonEmptyArray<c4.Link> | null;
|
|
142
|
-
steps: c4.
|
|
143
|
+
steps: c4.DynamicViewStep[];
|
|
143
144
|
rules: Array<c4.DynamicViewRule>;
|
|
144
145
|
variant: c4.DynamicViewDisplayVariant | undefined;
|
|
145
146
|
manualLayout?: c4.ViewManualLayout;
|
|
@@ -202,12 +203,6 @@ export declare function toRelationshipStyle(props: ast.RelationshipStyleProperty
|
|
|
202
203
|
head?: c4.RelationshipArrowType;
|
|
203
204
|
tail?: c4.RelationshipArrowType;
|
|
204
205
|
};
|
|
205
|
-
export declare function toRelationshipStyleExcludeDefaults(props: ast.SpecificationRelationshipKind['props'] | undefined, isValid: IsValidFn): {
|
|
206
|
-
tail?: any;
|
|
207
|
-
head?: any;
|
|
208
|
-
line?: any;
|
|
209
|
-
color?: any;
|
|
210
|
-
};
|
|
211
206
|
export declare function toColor(astNode: ast.ColorProperty): c4.Color | undefined;
|
|
212
207
|
export declare function toAutoLayout(rule: ast.ViewRuleAutoLayout): c4.ViewRuleAutoLayout;
|
|
213
208
|
export declare function toAstViewLayoutDirection(c4: c4.ViewRuleAutoLayout['direction']): ast.ViewLayoutDirection;
|
package/dist/ast.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor } from "@likec4/core";
|
|
2
1
|
import { nonexhaustive } from "@likec4/core/utils";
|
|
3
2
|
import { AstUtils, DocumentState } from "langium";
|
|
4
3
|
import { clamp, isNullish, isTruthy } from "remeda";
|
|
@@ -110,15 +109,6 @@ export function toRelationshipStyle(props, isValid) {
|
|
|
110
109
|
}
|
|
111
110
|
return result;
|
|
112
111
|
}
|
|
113
|
-
export function toRelationshipStyleExcludeDefaults(props, isValid) {
|
|
114
|
-
const { color, line, head, tail } = toRelationshipStyle(props?.filter(ast.isRelationshipStyleProperty), isValid);
|
|
115
|
-
return {
|
|
116
|
-
...color && color !== DefaultRelationshipColor ? { color } : {},
|
|
117
|
-
...line && line !== DefaultLineStyle ? { line } : {},
|
|
118
|
-
...head && head !== DefaultArrowType ? { head } : {},
|
|
119
|
-
...tail ? { tail } : {}
|
|
120
|
-
};
|
|
121
|
-
}
|
|
122
112
|
export function toColor(astNode) {
|
|
123
113
|
return astNode?.themeColor ?? astNode?.customColor?.$refText;
|
|
124
114
|
}
|