@likec4/language-server 1.0.0-next.0 → 1.0.0-next.2
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/model/model-builder.js +55 -52
- package/package.json +3 -3
|
@@ -185,7 +185,6 @@ ${printDocs(docs)}`);
|
|
|
185
185
|
langiumDocuments;
|
|
186
186
|
listeners = [];
|
|
187
187
|
async buildModel(cancelToken) {
|
|
188
|
-
await this.services.shared.workspace.DocumentBuilder.waitUntil(DocumentState.Validated, cancelToken);
|
|
189
188
|
return await this.services.shared.workspace.WorkspaceLock.read(async () => {
|
|
190
189
|
if (cancelToken) {
|
|
191
190
|
await interruptAndCheck(cancelToken);
|
|
@@ -209,35 +208,37 @@ ${printDocs(docs)}`);
|
|
|
209
208
|
if (!model) {
|
|
210
209
|
return null;
|
|
211
210
|
}
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
const cache = this.services.WorkspaceCache;
|
|
216
|
-
const viewsCache = this.services.WorkspaceCache;
|
|
217
|
-
return cache.get(MODEL_CACHE, () => {
|
|
218
|
-
const index = new LikeC4ModelGraph(model);
|
|
219
|
-
const allViews = [];
|
|
220
|
-
for (const view of R.values(model.views)) {
|
|
221
|
-
const result = computeView(view, index);
|
|
222
|
-
if (!result.isSuccess) {
|
|
223
|
-
logWarnError(result.error);
|
|
224
|
-
continue;
|
|
225
|
-
}
|
|
226
|
-
allViews.push(result.view);
|
|
211
|
+
return await this.services.shared.workspace.WorkspaceLock.read(async () => {
|
|
212
|
+
if (cancelToken) {
|
|
213
|
+
await interruptAndCheck(cancelToken);
|
|
227
214
|
}
|
|
228
|
-
|
|
229
|
-
const
|
|
230
|
-
|
|
231
|
-
const
|
|
232
|
-
|
|
233
|
-
|
|
215
|
+
const cache = this.services.WorkspaceCache;
|
|
216
|
+
const viewsCache = this.services.WorkspaceCache;
|
|
217
|
+
return cache.get(MODEL_CACHE, () => {
|
|
218
|
+
const index = new LikeC4ModelGraph(model);
|
|
219
|
+
const allViews = [];
|
|
220
|
+
for (const view of R.values(model.views)) {
|
|
221
|
+
const result = computeView(view, index);
|
|
222
|
+
if (!result.isSuccess) {
|
|
223
|
+
logWarnError(result.error);
|
|
224
|
+
continue;
|
|
225
|
+
}
|
|
226
|
+
allViews.push(result.view);
|
|
227
|
+
}
|
|
228
|
+
assignNavigateTo(allViews);
|
|
229
|
+
const views = R.mapToObj(allViews, (v) => {
|
|
230
|
+
const previous = this.previousViews[v.id];
|
|
231
|
+
const view = previous && eq(v, previous) ? previous : v;
|
|
232
|
+
viewsCache.set(computedViewKey(v.id), view);
|
|
233
|
+
return [v.id, view];
|
|
234
|
+
});
|
|
235
|
+
this.previousViews = { ...views };
|
|
236
|
+
return {
|
|
237
|
+
elements: model.elements,
|
|
238
|
+
relations: model.relations,
|
|
239
|
+
views
|
|
240
|
+
};
|
|
234
241
|
});
|
|
235
|
-
this.previousViews = { ...views };
|
|
236
|
-
return {
|
|
237
|
-
elements: model.elements,
|
|
238
|
-
relations: model.relations,
|
|
239
|
-
views
|
|
240
|
-
};
|
|
241
242
|
});
|
|
242
243
|
}
|
|
243
244
|
async computeView(viewId, cancelToken) {
|
|
@@ -247,33 +248,35 @@ ${printDocs(docs)}`);
|
|
|
247
248
|
logger.warn(`[ModelBuilder] Cannot find view ${viewId}`);
|
|
248
249
|
return null;
|
|
249
250
|
}
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
const cache = this.services.WorkspaceCache;
|
|
254
|
-
return cache.get(computedViewKey(viewId), () => {
|
|
255
|
-
const index = new LikeC4ModelGraph(model);
|
|
256
|
-
const result = computeView(view, index);
|
|
257
|
-
if (!result.isSuccess) {
|
|
258
|
-
logError(result.error);
|
|
259
|
-
return null;
|
|
251
|
+
return await this.services.shared.workspace.WorkspaceLock.read(async () => {
|
|
252
|
+
if (cancelToken) {
|
|
253
|
+
await interruptAndCheck(cancelToken);
|
|
260
254
|
}
|
|
261
|
-
const
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
if (navigateTo) {
|
|
269
|
-
node.navigateTo = navigateTo.id;
|
|
270
|
-
}
|
|
255
|
+
const cache = this.services.WorkspaceCache;
|
|
256
|
+
return cache.get(computedViewKey(viewId), () => {
|
|
257
|
+
const index = new LikeC4ModelGraph(model);
|
|
258
|
+
const result = computeView(view, index);
|
|
259
|
+
if (!result.isSuccess) {
|
|
260
|
+
logError(result.error);
|
|
261
|
+
return null;
|
|
271
262
|
}
|
|
263
|
+
const allElementViews = R.values(model.views).filter(
|
|
264
|
+
(v) => isStrictElementView(v) && v.id !== viewId
|
|
265
|
+
);
|
|
266
|
+
let computedView = result.view;
|
|
267
|
+
computedView.nodes.forEach((node) => {
|
|
268
|
+
if (!node.navigateTo) {
|
|
269
|
+
const navigateTo = R.find(allElementViews, (v) => v.viewOf === node.id);
|
|
270
|
+
if (navigateTo) {
|
|
271
|
+
node.navigateTo = navigateTo.id;
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
});
|
|
275
|
+
const previous = this.previousViews[viewId];
|
|
276
|
+
computedView = previous && eq(computedView, previous) ? previous : computedView;
|
|
277
|
+
this.previousViews[viewId] = computedView;
|
|
278
|
+
return computedView;
|
|
272
279
|
});
|
|
273
|
-
const previous = this.previousViews[viewId];
|
|
274
|
-
computedView = previous && eq(computedView, previous) ? previous : computedView;
|
|
275
|
-
this.previousViews[viewId] = computedView;
|
|
276
|
-
return computedView;
|
|
277
280
|
});
|
|
278
281
|
}
|
|
279
282
|
onModelParsed(callback) {
|
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.0.0-next.
|
|
4
|
+
"version": "1.0.0-next.2",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -74,8 +74,8 @@
|
|
|
74
74
|
"test": "vitest run"
|
|
75
75
|
},
|
|
76
76
|
"dependencies": {
|
|
77
|
-
"@likec4/core": "1.0.0-next.
|
|
78
|
-
"@likec4/graph": "1.0.0-next.
|
|
77
|
+
"@likec4/core": "1.0.0-next.2",
|
|
78
|
+
"@likec4/graph": "1.0.0-next.2",
|
|
79
79
|
"@total-typescript/ts-reset": "^0.5.1",
|
|
80
80
|
"debounce-fn": "^6.0.0",
|
|
81
81
|
"fast-equals": "^5.0.1",
|