@likec4/language-server 1.46.2 → 1.46.4
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/Rpc.js +66 -64
- package/dist/bundled.mjs +3249 -3173
- package/dist/generated/ast.js +2 -2
- package/dist/generated/grammar.js +1 -1
- package/dist/generated-lib/icons.js +7 -1
- package/dist/model/model-builder.js +6 -14
- package/dist/model-change/ModelChanges.js +69 -72
- package/dist/references/scope-provider.d.ts +1 -1
- package/dist/references/scope-provider.js +18 -21
- package/dist/workspace/IndexManager.js +4 -8
- package/dist/workspace/LangiumDocuments.d.ts +8 -2
- package/dist/workspace/LangiumDocuments.js +33 -25
- package/dist/workspace/ProjectsManager.d.ts +15 -8
- package/dist/workspace/ProjectsManager.js +131 -81
- package/dist/workspace/WorkspaceManager.d.ts +1 -1
- package/dist/workspace/WorkspaceManager.js +2 -6
- package/package.json +12 -12
- package/lib/package.json +0 -159
package/dist/Rpc.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { filter,
|
|
1
|
+
import { filter, funnel, indexBy, keys, map, mapValues, pipe, sort } from 'remeda';
|
|
2
2
|
import { logger as rootLogger } from './logger';
|
|
3
3
|
import { invariant, nonexhaustive, } from '@likec4/core';
|
|
4
4
|
import { LikeC4Model } from '@likec4/core/model';
|
|
@@ -43,7 +43,7 @@ export class Rpc extends ADisposable {
|
|
|
43
43
|
});
|
|
44
44
|
let isFirstBuild = true;
|
|
45
45
|
this.onDispose(likec4Services.ModelBuilder.onModelParsed(() => notifyModelParsed.call(1)), connection.onRequest(FetchComputedModel.req, async ({ projectId, cleanCaches }, cancelToken) => {
|
|
46
|
-
logger.debug `received request ${'fetchComputedModel'} for project ${projectId}`;
|
|
46
|
+
logger.debug `received request ${'fetchComputedModel'} for project ${projectId} (cleanCaches: ${cleanCaches})`;
|
|
47
47
|
if (cleanCaches) {
|
|
48
48
|
const docs = projectId
|
|
49
49
|
? LangiumDocuments.projectDocuments(projectId)
|
|
@@ -53,7 +53,7 @@ export class Rpc extends ADisposable {
|
|
|
53
53
|
}
|
|
54
54
|
const likec4model = await likec4Services.ModelBuilder.computeModel(projectId, cancelToken);
|
|
55
55
|
if (likec4model !== LikeC4Model.EMPTY) {
|
|
56
|
-
return { model: likec4model.$
|
|
56
|
+
return { model: likec4model.$data };
|
|
57
57
|
}
|
|
58
58
|
return { model: null };
|
|
59
59
|
}), connection.onNotification(DidChangeSnapshotNotification.type, async ({ snapshotUri }) => {
|
|
@@ -105,38 +105,41 @@ export class Rpc extends ADisposable {
|
|
|
105
105
|
};
|
|
106
106
|
}),
|
|
107
107
|
};
|
|
108
|
-
}), connection.onRequest(ReloadProjects.req, async () => {
|
|
108
|
+
}), connection.onRequest(ReloadProjects.req, async (cancelToken) => {
|
|
109
109
|
logger.debug `received request ${'ReloadProjects'}`;
|
|
110
110
|
likec4Services.ManualLayouts.clearCaches();
|
|
111
|
-
await projects.reloadProjects();
|
|
111
|
+
await projects.reloadProjects(cancelToken);
|
|
112
112
|
return;
|
|
113
|
-
}), connection.onRequest(RegisterProject.req, async (params) => {
|
|
113
|
+
}), connection.onRequest(RegisterProject.req, async (params, cancelToken) => {
|
|
114
114
|
logger.debug `received request ${'RegisterProject'}`;
|
|
115
|
-
const project = await projects.registerProject(params);
|
|
115
|
+
const project = await projects.registerProject(params, cancelToken);
|
|
116
116
|
return { id: project.id };
|
|
117
117
|
}), connection.onRequest(FetchViewsFromAllProjects.req, async (cancelToken) => {
|
|
118
118
|
logger.debug `received request ${'FetchViewsFromAllProjects'}`;
|
|
119
|
-
const
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
119
|
+
const views = [];
|
|
120
|
+
for (const projectId of projects.all) {
|
|
121
|
+
await interruptAndCheck(cancelToken);
|
|
122
|
+
try {
|
|
123
|
+
const computedViews = await likec4Services.Views.computedViews(projectId, cancelToken);
|
|
124
|
+
views.push(...pipe(computedViews, map(v => ({
|
|
125
|
+
id: v.id,
|
|
126
|
+
title: v.title ?? v.id,
|
|
127
|
+
projectId,
|
|
128
|
+
})), sort((a, b) => {
|
|
129
|
+
if (a.id === 'index') {
|
|
130
|
+
return -1;
|
|
131
|
+
}
|
|
132
|
+
if (b.id === 'index') {
|
|
133
|
+
return 1;
|
|
134
|
+
}
|
|
135
|
+
return a.title.localeCompare(b.title);
|
|
136
|
+
})));
|
|
137
|
+
}
|
|
138
|
+
catch (error) {
|
|
139
|
+
logger.warn(`Failed to fetch views for project ${projectId}:`, { error });
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return { views };
|
|
140
143
|
}), connection.onRequest(BuildDocuments.req, async ({ docs }, cancelToken) => {
|
|
141
144
|
const changed = docs.map(d => URI.parse(d));
|
|
142
145
|
const notChanged = (uri) => changed.every(c => !UriUtils.equals(c, uri));
|
|
@@ -186,52 +189,51 @@ export class Rpc extends ADisposable {
|
|
|
186
189
|
default:
|
|
187
190
|
nonexhaustive(params);
|
|
188
191
|
}
|
|
189
|
-
}), connection.onRequest(ChangeView.req, async (request,
|
|
192
|
+
}), connection.onRequest(ChangeView.req, async (request, cancelToken) => {
|
|
190
193
|
logger.debug `received request ${'changeView'} of ${request.viewId} from project ${request.projectId}`;
|
|
191
194
|
const loc = await likec4Services.ModelChanges.applyChange(request);
|
|
192
195
|
const op = request.change.op;
|
|
193
196
|
if (request.projectId &&
|
|
194
197
|
(op === 'save-view-snapshot' || op === 'reset-manual-layout')) {
|
|
195
|
-
await projects.rebuidProject(request.projectId);
|
|
198
|
+
await projects.rebuidProject(request.projectId, cancelToken);
|
|
196
199
|
}
|
|
197
200
|
return loc;
|
|
198
201
|
}), connection.onRequest(FetchTelemetryMetrics.req, async (cancelToken) => {
|
|
199
|
-
|
|
200
|
-
const
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
202
|
+
let metrics = null;
|
|
203
|
+
for (const projectId of projects.all) {
|
|
204
|
+
try {
|
|
205
|
+
const model = await likec4Services.ModelBuilder.computeModel(projectId, cancelToken);
|
|
206
|
+
if (model === LikeC4Model.EMPTY) {
|
|
207
|
+
continue;
|
|
208
|
+
}
|
|
209
|
+
metrics ??= {
|
|
210
|
+
elementKinds: 0,
|
|
211
|
+
deploymentKinds: 0,
|
|
212
|
+
relationshipKinds: 0,
|
|
213
|
+
tags: 0,
|
|
214
|
+
customColors: 0,
|
|
215
|
+
elements: 0,
|
|
216
|
+
deploymentNodes: 0,
|
|
217
|
+
relationships: 0,
|
|
218
|
+
views: 0,
|
|
219
|
+
projects: 0,
|
|
220
|
+
};
|
|
221
|
+
metrics.elementKinds += keys(model.specification.elements).length;
|
|
222
|
+
metrics.deploymentKinds += keys(model.specification.deployments).length;
|
|
223
|
+
metrics.relationshipKinds += keys(model.specification.relationships).length;
|
|
224
|
+
metrics.tags += keys(model.specification.tags).length;
|
|
225
|
+
metrics.customColors += keys(model.specification.customColors ?? {}).length;
|
|
226
|
+
metrics.elements += keys(model.$data.elements).length;
|
|
227
|
+
metrics.deploymentNodes += [...model.deployment.nodes()].length;
|
|
228
|
+
metrics.relationships += keys(model.$data.relations).length;
|
|
229
|
+
metrics.views += keys(model.$data.views).length;
|
|
230
|
+
metrics.projects += 1;
|
|
204
231
|
}
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
tags: keys(model.specification.tags).length,
|
|
210
|
-
customColors: keys(model.specification.customColors ?? {}).length,
|
|
211
|
-
elements: keys(model.$data.elements).length,
|
|
212
|
-
deploymentNodes: [...model.deployment.nodes()].length,
|
|
213
|
-
relationships: keys(model.$data.relations).length,
|
|
214
|
-
views: keys(model.$data.views).length,
|
|
215
|
-
projects: 1,
|
|
216
|
-
};
|
|
217
|
-
});
|
|
218
|
-
const results = await Promise.allSettled(promises);
|
|
232
|
+
catch (err) {
|
|
233
|
+
logger.warn(`Error fetching telemetry metrics for project ${projectId}`, { err });
|
|
234
|
+
}
|
|
235
|
+
}
|
|
219
236
|
await interruptAndCheck(cancelToken);
|
|
220
|
-
const values = results.filter(r => r.status === 'fulfilled').map(r => r.value);
|
|
221
|
-
const metrics = values.length > 0
|
|
222
|
-
? values.reduce((acc, r) => ({
|
|
223
|
-
elementKinds: acc.elementKinds + r.elementKinds,
|
|
224
|
-
deploymentKinds: acc.deploymentKinds + r.deploymentKinds,
|
|
225
|
-
relationshipKinds: acc.relationshipKinds + r.relationshipKinds,
|
|
226
|
-
tags: acc.tags + r.tags,
|
|
227
|
-
customColors: acc.customColors + r.customColors,
|
|
228
|
-
elements: acc.elements + r.elements,
|
|
229
|
-
deploymentNodes: acc.deploymentNodes + r.deploymentNodes,
|
|
230
|
-
relationships: acc.relationships + r.relationships,
|
|
231
|
-
views: acc.views + r.views,
|
|
232
|
-
projects: acc.projects + 1,
|
|
233
|
-
}))
|
|
234
|
-
: null;
|
|
235
237
|
return {
|
|
236
238
|
metrics,
|
|
237
239
|
};
|