@likec4/language-server 0.54.0 → 0.57.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/Rpc.js +3 -10
- package/dist/browser/index.d.ts +9 -0
- package/dist/browser/index.js +16 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.js +1 -1
- package/dist/model/fqn-index.d.ts +1 -1
- package/dist/model/fqn-index.js +2 -2
- package/dist/model/model-builder.d.ts +2 -1
- package/dist/model/model-builder.js +51 -33
- package/dist/module.d.ts +8 -3
- package/dist/module.js +44 -10
- package/dist/node/index.d.ts +6 -0
- package/dist/node/index.js +13 -0
- package/dist/test/testServices.d.ts +3 -2
- package/dist/test/testServices.js +25 -21
- package/dist/{utils.d.ts → utils/printDocs.d.ts} +1 -2
- package/dist/{utils.js → utils/printDocs.js} +0 -3
- package/package.json +26 -10
package/dist/Rpc.js
CHANGED
|
@@ -1,16 +1,9 @@
|
|
|
1
|
-
import { logError, logger } from "./logger.js";
|
|
2
1
|
import debounceFunction from "debounce-fn";
|
|
2
|
+
import { logError, logger } from "./logger.js";
|
|
3
3
|
import { nonexhaustive } from "@likec4/core";
|
|
4
4
|
import { URI, UriUtils } from "langium";
|
|
5
5
|
import { isLikeC4LangiumDocument } from "./ast.js";
|
|
6
|
-
import {
|
|
7
|
-
buildDocuments,
|
|
8
|
-
computeView,
|
|
9
|
-
fetchModel,
|
|
10
|
-
fetchRawModel,
|
|
11
|
-
locate,
|
|
12
|
-
onDidChangeModel
|
|
13
|
-
} from "./protocol.js";
|
|
6
|
+
import { buildDocuments, computeView, fetchModel, fetchRawModel, locate, onDidChangeModel } from "./protocol.js";
|
|
14
7
|
export class Rpc {
|
|
15
8
|
constructor(services) {
|
|
16
9
|
this.services = services;
|
|
@@ -32,7 +25,7 @@ export class Rpc {
|
|
|
32
25
|
{
|
|
33
26
|
before: true,
|
|
34
27
|
after: true,
|
|
35
|
-
wait:
|
|
28
|
+
wait: 250,
|
|
36
29
|
maxWait: 1e3
|
|
37
30
|
}
|
|
38
31
|
)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BrowserMessageReader, BrowserMessageWriter } from 'vscode-languageserver/browser';
|
|
2
|
+
export declare function startLanguageServer(): {
|
|
3
|
+
connection: import("vscode-languageserver/browser").Connection;
|
|
4
|
+
messageReader: BrowserMessageReader;
|
|
5
|
+
messageWriter: BrowserMessageWriter;
|
|
6
|
+
shared: import("../module").LikeC4SharedServices;
|
|
7
|
+
likec4: import("../module").LikeC4Services;
|
|
8
|
+
};
|
|
9
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EmptyFileSystem, startLanguageServer as startLanguim } from "langium";
|
|
2
|
+
import { BrowserMessageReader, BrowserMessageWriter, createConnection } from "vscode-languageserver/browser";
|
|
3
|
+
import { createLanguageServices } from "../module.js";
|
|
4
|
+
export function startLanguageServer() {
|
|
5
|
+
const messageReader = new BrowserMessageReader(self);
|
|
6
|
+
const messageWriter = new BrowserMessageWriter(self);
|
|
7
|
+
const connection = createConnection(messageReader, messageWriter);
|
|
8
|
+
const services = createLanguageServices({ connection, ...EmptyFileSystem });
|
|
9
|
+
startLanguim(services.shared);
|
|
10
|
+
return {
|
|
11
|
+
...services,
|
|
12
|
+
connection,
|
|
13
|
+
messageReader,
|
|
14
|
+
messageWriter
|
|
15
|
+
};
|
|
16
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { logger } from './logger';
|
|
2
|
-
export { createLanguageServices } from './module';
|
|
3
|
-
export type { LikeC4Services } from './module';
|
|
2
|
+
export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from './module';
|
|
3
|
+
export type { LanguageServicesContext, LikeC4Services, LikeC4SharedServices } from './module';
|
|
4
4
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export { logger } from "./logger.js";
|
|
2
|
-
export { createLanguageServices } from "./module.js";
|
|
2
|
+
export { createCustomLanguageServices, createLanguageServices, LikeC4Module } from "./module.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Fqn } from '@likec4/core';
|
|
2
2
|
import type { LangiumDocuments, Stream } from 'langium';
|
|
3
|
-
import type {
|
|
3
|
+
import type { ast, FqnIndexedDocument } from '../ast';
|
|
4
4
|
import type { LikeC4Services } from '../module';
|
|
5
5
|
export interface FqnIndexEntry {
|
|
6
6
|
fqn: Fqn;
|
package/dist/model/fqn-index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { nameFromFqn, parentFqn } from "@likec4/core";
|
|
2
|
-
import {
|
|
2
|
+
import { DocumentState, DONE_RESULT, MultiMap, stream, StreamImpl } from "langium";
|
|
3
3
|
import { ElementOps, isFqnIndexedDocument, isLikeC4LangiumDocument } from "../ast.js";
|
|
4
4
|
import { logError, logger } from "../logger.js";
|
|
5
|
-
import { printDocs } from "../utils.js";
|
|
5
|
+
import { printDocs } from "../utils/printDocs.js";
|
|
6
6
|
import { computeDocumentFqn } from "./fqn-computation.js";
|
|
7
7
|
const True = () => true;
|
|
8
8
|
export class FqnIndex {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type c4, type ViewID } from '@likec4/core';
|
|
2
2
|
import type { URI } from 'langium';
|
|
3
3
|
import { Disposable } from 'vscode-languageserver';
|
|
4
4
|
import type { LikeC4Services } from '../module';
|
|
@@ -9,6 +9,7 @@ export declare class LikeC4ModelBuilder {
|
|
|
9
9
|
private listeners;
|
|
10
10
|
constructor(services: LikeC4Services);
|
|
11
11
|
buildRawModel(): c4.LikeC4RawModel | null;
|
|
12
|
+
private previousViews;
|
|
12
13
|
buildModel(): c4.LikeC4Model | null;
|
|
13
14
|
computeView(viewId: ViewID): c4.ComputedView | null;
|
|
14
15
|
onModelParsed(callback: ModelParsedListener): Disposable;
|
|
@@ -3,13 +3,13 @@ import {
|
|
|
3
3
|
isStrictElementView,
|
|
4
4
|
parentFqn
|
|
5
5
|
} from "@likec4/core";
|
|
6
|
-
import {
|
|
6
|
+
import { computeView, LikeC4ModelGraph } from "@likec4/graph";
|
|
7
7
|
import { DocumentState } from "langium";
|
|
8
8
|
import * as R from "remeda";
|
|
9
9
|
import { Disposable } from "vscode-languageserver";
|
|
10
10
|
import { isParsedLikeC4LangiumDocument } from "../ast.js";
|
|
11
|
-
import { logError,
|
|
12
|
-
import { printDocs } from "../utils.js";
|
|
11
|
+
import { logError, logger, logWarnError } from "../logger.js";
|
|
12
|
+
import { printDocs } from "../utils/printDocs.js";
|
|
13
13
|
import { assignNavigateTo, resolveRelativePaths, resolveRulesExtendedViews } from "../view-utils/index.js";
|
|
14
14
|
function buildModel(services, docs) {
|
|
15
15
|
const c4Specification = {
|
|
@@ -20,9 +20,7 @@ function buildModel(services, docs) {
|
|
|
20
20
|
Object.assign(c4Specification.kinds, spec.kinds), Object.assign(c4Specification.relationships, spec.relationships);
|
|
21
21
|
});
|
|
22
22
|
const resolveLinks = (doc, links) => {
|
|
23
|
-
return links.map(
|
|
24
|
-
(l) => services.lsp.DocumentLinkProvider.resolveLink(doc, l)
|
|
25
|
-
);
|
|
23
|
+
return links.map((l) => services.lsp.DocumentLinkProvider.resolveLink(doc, l));
|
|
26
24
|
};
|
|
27
25
|
const toModelElement = (doc) => {
|
|
28
26
|
return ({ astPath, tags, links, ...parsed }) => {
|
|
@@ -168,7 +166,7 @@ ${printDocs(docs)}`);
|
|
|
168
166
|
if (parsed.length > 0) {
|
|
169
167
|
this.notifyListeners(parsed);
|
|
170
168
|
}
|
|
171
|
-
return Promise.resolve();
|
|
169
|
+
return await Promise.resolve();
|
|
172
170
|
}
|
|
173
171
|
);
|
|
174
172
|
logger.debug(`[ModelBuilder] Created`);
|
|
@@ -193,57 +191,74 @@ ${printDocs(docs)}`);
|
|
|
193
191
|
}
|
|
194
192
|
});
|
|
195
193
|
}
|
|
194
|
+
previousViews = {};
|
|
196
195
|
buildModel() {
|
|
197
196
|
const cache = this.services.WorkspaceCache;
|
|
197
|
+
const viewsCache = this.services.WorkspaceCache;
|
|
198
198
|
return cache.get(MODEL_CACHE, () => {
|
|
199
199
|
const model = this.buildRawModel();
|
|
200
200
|
if (!model) {
|
|
201
201
|
return null;
|
|
202
202
|
}
|
|
203
203
|
const index = new LikeC4ModelGraph(model);
|
|
204
|
-
const
|
|
204
|
+
const allViews = [];
|
|
205
205
|
for (const view of R.values(model.views)) {
|
|
206
206
|
const result = computeView(view, index);
|
|
207
207
|
if (!result.isSuccess) {
|
|
208
208
|
logWarnError(result.error);
|
|
209
209
|
continue;
|
|
210
210
|
}
|
|
211
|
-
|
|
211
|
+
allViews.push(result.view);
|
|
212
212
|
}
|
|
213
|
-
assignNavigateTo(
|
|
213
|
+
assignNavigateTo(allViews);
|
|
214
|
+
const views = R.mapToObj(allViews, (v) => {
|
|
215
|
+
const previous = this.previousViews[v.id];
|
|
216
|
+
const view = previous && R.equals(v, previous) ? previous : v;
|
|
217
|
+
viewsCache.set(computedViewKey(v.id), view);
|
|
218
|
+
return [v.id, view];
|
|
219
|
+
});
|
|
220
|
+
this.previousViews = { ...views };
|
|
214
221
|
return {
|
|
215
222
|
elements: model.elements,
|
|
216
223
|
relations: model.relations,
|
|
217
|
-
views
|
|
224
|
+
views
|
|
218
225
|
};
|
|
219
226
|
});
|
|
220
227
|
}
|
|
221
228
|
computeView(viewId) {
|
|
222
|
-
const
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
if (navigateTo) {
|
|
242
|
-
|
|
229
|
+
const cache = this.services.WorkspaceCache;
|
|
230
|
+
return cache.get(computedViewKey(viewId), () => {
|
|
231
|
+
const model = this.buildRawModel();
|
|
232
|
+
const view = model?.views[viewId];
|
|
233
|
+
if (!view) {
|
|
234
|
+
logger.warn(`[ModelBuilder] Cannot find view ${viewId}`);
|
|
235
|
+
return null;
|
|
236
|
+
}
|
|
237
|
+
const index = new LikeC4ModelGraph(model);
|
|
238
|
+
const result = computeView(view, index);
|
|
239
|
+
if (!result.isSuccess) {
|
|
240
|
+
logError(result.error);
|
|
241
|
+
return null;
|
|
242
|
+
}
|
|
243
|
+
const allElementViews = R.values(model.views).filter(
|
|
244
|
+
(v) => isStrictElementView(v) && v.id !== viewId
|
|
245
|
+
);
|
|
246
|
+
let computedView = result.view;
|
|
247
|
+
computedView.nodes.forEach((node) => {
|
|
248
|
+
if (!node.navigateTo) {
|
|
249
|
+
const navigateTo = R.find(allElementViews, (v) => v.viewOf === node.id);
|
|
250
|
+
if (navigateTo) {
|
|
251
|
+
node.navigateTo = navigateTo.id;
|
|
252
|
+
}
|
|
243
253
|
}
|
|
254
|
+
});
|
|
255
|
+
const previous = this.previousViews[viewId];
|
|
256
|
+
if (previous) {
|
|
257
|
+
computedView = R.equals(computedView, previous) ? previous : computedView;
|
|
244
258
|
}
|
|
259
|
+
this.previousViews[viewId] = computedView;
|
|
260
|
+
return computedView;
|
|
245
261
|
});
|
|
246
|
-
return computedView;
|
|
247
262
|
}
|
|
248
263
|
onModelParsed(callback) {
|
|
249
264
|
this.listeners.push(callback);
|
|
@@ -267,3 +282,6 @@ ${printDocs(docs)}`);
|
|
|
267
282
|
}
|
|
268
283
|
}
|
|
269
284
|
}
|
|
285
|
+
function computedViewKey(viewId) {
|
|
286
|
+
return `computed-view-${viewId}`;
|
|
287
|
+
}
|
package/dist/module.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Rpc } from './Rpc';
|
|
1
|
+
import { type DefaultSharedModuleContext, type LangiumServices, type LangiumSharedServices, type Module, type PartialLangiumServices, WorkspaceCache } from 'langium';
|
|
3
2
|
import { LikeC4CodeLensProvider, LikeC4DocumentHighlightProvider, LikeC4DocumentLinkProvider, LikeC4DocumentSymbolProvider, LikeC4HoverProvider, LikeC4SemanticTokenProvider } from './lsp';
|
|
4
3
|
import { FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from './model';
|
|
5
4
|
import { LikeC4ScopeComputation, LikeC4ScopeProvider } from './references';
|
|
5
|
+
import { Rpc } from './Rpc';
|
|
6
6
|
import { LikeC4WorkspaceManager, NodeKindProvider, WorkspaceSymbolProvider } from './shared';
|
|
7
7
|
interface LikeC4AddedSharedServices {
|
|
8
8
|
lsp: {
|
|
@@ -42,7 +42,12 @@ export interface LikeC4AddedServices {
|
|
|
42
42
|
}
|
|
43
43
|
export type LikeC4Services = LangiumServices & LikeC4AddedServices;
|
|
44
44
|
export declare const LikeC4Module: Module<LikeC4Services, PartialLangiumServices & LikeC4AddedServices>;
|
|
45
|
-
type LanguageServicesContext = Partial<DefaultSharedModuleContext>;
|
|
45
|
+
export type LanguageServicesContext = Partial<DefaultSharedModuleContext>;
|
|
46
|
+
export declare function createCustomLanguageServices<I1, I2, I3, I extends I1 & I2 & I3 & LikeC4Services>(context: LanguageServicesContext, module: Module<I, I1>, module2?: Module<I, I2>, module3?: Module<I, I3>): {
|
|
47
|
+
shared: LikeC4SharedServices;
|
|
48
|
+
likec4: I;
|
|
49
|
+
};
|
|
50
|
+
export declare function createSharedServices(context?: LanguageServicesContext): LikeC4SharedServices;
|
|
46
51
|
export declare function createLanguageServices(context?: LanguageServicesContext): {
|
|
47
52
|
shared: LikeC4SharedServices;
|
|
48
53
|
likec4: LikeC4Services;
|
package/dist/module.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { normalizeError } from "@likec4/core";
|
|
2
2
|
import {
|
|
3
|
-
EmptyFileSystem,
|
|
4
|
-
WorkspaceCache,
|
|
5
3
|
createDefaultModule,
|
|
6
4
|
createDefaultSharedModule,
|
|
7
|
-
|
|
5
|
+
EmptyFileSystem,
|
|
6
|
+
inject,
|
|
7
|
+
WorkspaceCache
|
|
8
8
|
} from "langium";
|
|
9
|
-
import { Rpc } from "./Rpc.js";
|
|
10
9
|
import { LikeC4GeneratedModule, LikeC4GeneratedSharedModule } from "./generated/module.js";
|
|
11
10
|
import { logger } from "./logger.js";
|
|
12
11
|
import {
|
|
@@ -19,6 +18,7 @@ import {
|
|
|
19
18
|
} from "./lsp/index.js";
|
|
20
19
|
import { FqnIndex, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from "./model/index.js";
|
|
21
20
|
import { LikeC4ScopeComputation, LikeC4ScopeProvider } from "./references/index.js";
|
|
21
|
+
import { Rpc } from "./Rpc.js";
|
|
22
22
|
import { LikeC4WorkspaceManager, NodeKindProvider, WorkspaceSymbolProvider } from "./shared/index.js";
|
|
23
23
|
import { registerValidationChecks } from "./validation/index.js";
|
|
24
24
|
const LikeC4SharedModule = {
|
|
@@ -55,8 +55,24 @@ export const LikeC4Module = {
|
|
|
55
55
|
ScopeProvider: bind(LikeC4ScopeProvider)
|
|
56
56
|
}
|
|
57
57
|
};
|
|
58
|
-
export function
|
|
59
|
-
const
|
|
58
|
+
export function createCustomLanguageServices(context, module, module2, module3) {
|
|
59
|
+
const shared = createSharedServices(context);
|
|
60
|
+
const modules = [
|
|
61
|
+
createDefaultModule({ shared }),
|
|
62
|
+
LikeC4GeneratedModule,
|
|
63
|
+
LikeC4Module,
|
|
64
|
+
module,
|
|
65
|
+
module2,
|
|
66
|
+
module3
|
|
67
|
+
].reduce(_merge, {});
|
|
68
|
+
const likec4 = inject(modules);
|
|
69
|
+
shared.ServiceRegistry.register(likec4);
|
|
70
|
+
registerValidationChecks(likec4);
|
|
71
|
+
likec4.Rpc.init();
|
|
72
|
+
return { shared, likec4 };
|
|
73
|
+
}
|
|
74
|
+
export function createSharedServices(context = {}) {
|
|
75
|
+
const connection = context.connection;
|
|
60
76
|
if (connection) {
|
|
61
77
|
const original = logger.error.bind(logger);
|
|
62
78
|
logger.error = (arg) => {
|
|
@@ -65,23 +81,41 @@ export function createLanguageServices(context) {
|
|
|
65
81
|
connection.telemetry.logEvent({ eventName: "error", error: arg });
|
|
66
82
|
return;
|
|
67
83
|
}
|
|
68
|
-
const
|
|
84
|
+
const error = normalizeError(arg);
|
|
69
85
|
original(error);
|
|
70
|
-
connection.telemetry.logEvent({ eventName: "error", error: message });
|
|
86
|
+
connection.telemetry.logEvent({ eventName: "error", error: error.stack ?? error.message });
|
|
71
87
|
};
|
|
72
88
|
}
|
|
73
89
|
const moduleContext = {
|
|
74
90
|
...EmptyFileSystem,
|
|
75
91
|
...context
|
|
76
92
|
};
|
|
77
|
-
|
|
93
|
+
return inject(
|
|
78
94
|
createDefaultSharedModule(moduleContext),
|
|
79
95
|
LikeC4GeneratedSharedModule,
|
|
80
96
|
LikeC4SharedModule
|
|
81
97
|
);
|
|
98
|
+
}
|
|
99
|
+
export function createLanguageServices(context = {}) {
|
|
100
|
+
const shared = createSharedServices(context);
|
|
82
101
|
const likec4 = inject(createDefaultModule({ shared }), LikeC4GeneratedModule, LikeC4Module);
|
|
83
102
|
shared.ServiceRegistry.register(likec4);
|
|
84
103
|
registerValidationChecks(likec4);
|
|
85
104
|
likec4.Rpc.init();
|
|
86
105
|
return { shared, likec4 };
|
|
87
106
|
}
|
|
107
|
+
function _merge(target, source) {
|
|
108
|
+
if (source) {
|
|
109
|
+
for (const [key, value2] of Object.entries(source)) {
|
|
110
|
+
if (value2 !== void 0) {
|
|
111
|
+
const value1 = target[key];
|
|
112
|
+
if (value1 !== null && value2 !== null && typeof value1 === "object" && typeof value2 === "object") {
|
|
113
|
+
target[key] = _merge(value1, value2);
|
|
114
|
+
} else {
|
|
115
|
+
target[key] = value2;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
return target;
|
|
121
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export declare function startLanguageServer(): {
|
|
2
|
+
connection: import("vscode-languageserver/node")._Connection<import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/node")._, import("vscode-languageserver/lib/common/inlineCompletion.proposed").InlineCompletionFeatureShape, import("vscode-languageserver/node")._>;
|
|
3
|
+
shared: import("../module").LikeC4SharedServices;
|
|
4
|
+
likec4: import("../module").LikeC4Services;
|
|
5
|
+
};
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { startLanguageServer as startLanguim } from "langium";
|
|
2
|
+
import { NodeFileSystem } from "langium/node";
|
|
3
|
+
import { createConnection, ProposedFeatures } from "vscode-languageserver/node";
|
|
4
|
+
import { createLanguageServices } from "../module.js";
|
|
5
|
+
export function startLanguageServer() {
|
|
6
|
+
const connection = createConnection(ProposedFeatures.all);
|
|
7
|
+
const services = createLanguageServices({ connection, ...NodeFileSystem });
|
|
8
|
+
startLanguim(services.shared);
|
|
9
|
+
return {
|
|
10
|
+
...services,
|
|
11
|
+
connection
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1,15 +1,16 @@
|
|
|
1
|
+
import { type Diagnostic } from 'vscode-languageserver-protocol';
|
|
1
2
|
import type { LikeC4LangiumDocument } from '../ast';
|
|
2
3
|
export declare function createTestServices(workspace?: string): {
|
|
3
4
|
services: import("../module").LikeC4Services;
|
|
4
5
|
parse: (input: string, uri?: string) => Promise<LikeC4LangiumDocument>;
|
|
5
6
|
validate: (input: string | LikeC4LangiumDocument, uri?: string) => Promise<{
|
|
6
7
|
document: LikeC4LangiumDocument;
|
|
7
|
-
diagnostics: (
|
|
8
|
+
diagnostics: (Diagnostic & import("langium").DiagnosticInfo<import("../ast").LikeC4AstNode>)[];
|
|
8
9
|
warnings: string[];
|
|
9
10
|
errors: string[];
|
|
10
11
|
}>;
|
|
11
12
|
validateAll: () => Promise<{
|
|
12
|
-
diagnostics:
|
|
13
|
+
diagnostics: Diagnostic[];
|
|
13
14
|
errors: string[];
|
|
14
15
|
warnings: string[];
|
|
15
16
|
}>;
|
|
@@ -42,12 +42,8 @@ export function createTestServices(workspace = "file:///test/workspace") {
|
|
|
42
42
|
const document = typeof input === "string" ? await parse(input, uri) : input;
|
|
43
43
|
await documentBuilder.build([document], { validation: true });
|
|
44
44
|
const diagnostics = document.diagnostics ?? [];
|
|
45
|
-
const warnings = diagnostics.flatMap(
|
|
46
|
-
|
|
47
|
-
);
|
|
48
|
-
const errors = diagnostics.flatMap(
|
|
49
|
-
(d) => d.severity === DiagnosticSeverity.Error ? d.message : []
|
|
50
|
-
);
|
|
45
|
+
const warnings = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Warning ? d.message : []);
|
|
46
|
+
const errors = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Error ? d.message : []);
|
|
51
47
|
return {
|
|
52
48
|
document,
|
|
53
49
|
diagnostics,
|
|
@@ -55,22 +51,30 @@ export function createTestServices(workspace = "file:///test/workspace") {
|
|
|
55
51
|
errors
|
|
56
52
|
};
|
|
57
53
|
};
|
|
54
|
+
let previousPromise = Promise.resolve();
|
|
58
55
|
const validateAll = async () => {
|
|
59
|
-
const
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
(d) => d.severity === DiagnosticSeverity.Warning ? d.message : []
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
56
|
+
const currentPromise = previousPromise.then(async () => {
|
|
57
|
+
const docs = langiumDocuments.all.toArray();
|
|
58
|
+
assert.ok(docs.length > 0, "no documents to validate");
|
|
59
|
+
await documentBuilder.build(docs, { validation: true });
|
|
60
|
+
const diagnostics = docs.flatMap((doc) => doc.diagnostics ?? []);
|
|
61
|
+
const warnings = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Warning ? d.message : []);
|
|
62
|
+
const errors = diagnostics.flatMap((d) => d.severity === DiagnosticSeverity.Error ? d.message : []);
|
|
63
|
+
return {
|
|
64
|
+
diagnostics,
|
|
65
|
+
errors,
|
|
66
|
+
warnings
|
|
67
|
+
};
|
|
68
|
+
}).catch((e) => {
|
|
69
|
+
console.error(e);
|
|
70
|
+
return Promise.resolve({
|
|
71
|
+
diagnostics: [],
|
|
72
|
+
errors: [],
|
|
73
|
+
warnings: []
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
previousPromise = currentPromise;
|
|
77
|
+
return await currentPromise;
|
|
74
78
|
};
|
|
75
79
|
const buildModel = async () => {
|
|
76
80
|
await validateAll();
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@likec4/language-server",
|
|
3
3
|
"description": "LikeC4 Language Server",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.57.0",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"bugs": "https://github.com/likec4/likec4/issues",
|
|
7
7
|
"homepage": "https://likec4.dev",
|
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
"dist",
|
|
11
11
|
"contrib",
|
|
12
12
|
"!**/__mocks__/",
|
|
13
|
-
"!**/
|
|
13
|
+
"!**/__tests__/",
|
|
14
14
|
"!**/*.spec.*",
|
|
15
15
|
"!**/*.map"
|
|
16
16
|
],
|
|
@@ -24,6 +24,14 @@
|
|
|
24
24
|
".": {
|
|
25
25
|
"types": "./dist/index.d.ts",
|
|
26
26
|
"default": "./dist/index.js"
|
|
27
|
+
},
|
|
28
|
+
"./browser": {
|
|
29
|
+
"types": "./dist/browser/index.d.ts",
|
|
30
|
+
"default": "./dist/browser/index.js"
|
|
31
|
+
},
|
|
32
|
+
"./node": {
|
|
33
|
+
"types": "./dist/node/index.d.ts",
|
|
34
|
+
"default": "./dist/node/index.js"
|
|
27
35
|
}
|
|
28
36
|
},
|
|
29
37
|
"publishConfig": {
|
|
@@ -33,6 +41,14 @@
|
|
|
33
41
|
".": {
|
|
34
42
|
"types": "./dist/index.d.ts",
|
|
35
43
|
"default": "./dist/index.js"
|
|
44
|
+
},
|
|
45
|
+
"./browser": {
|
|
46
|
+
"types": "./dist/browser/index.d.ts",
|
|
47
|
+
"default": "./dist/browser/index.js"
|
|
48
|
+
},
|
|
49
|
+
"./node": {
|
|
50
|
+
"types": "./dist/node/index.d.ts",
|
|
51
|
+
"default": "./dist/node/index.js"
|
|
36
52
|
}
|
|
37
53
|
}
|
|
38
54
|
},
|
|
@@ -50,32 +66,32 @@
|
|
|
50
66
|
"test": "vitest run"
|
|
51
67
|
},
|
|
52
68
|
"dependencies": {
|
|
53
|
-
"@likec4/core": "0.
|
|
54
|
-
"@likec4/graph": "0.
|
|
69
|
+
"@likec4/core": "0.57.0",
|
|
70
|
+
"@likec4/graph": "0.57.0",
|
|
55
71
|
"debounce-fn": "^6.0.0",
|
|
56
72
|
"langium": "^2.1.3",
|
|
57
73
|
"object-hash": "^3.0.0",
|
|
58
74
|
"p-debounce": "^4.0.0",
|
|
59
75
|
"rambdax": "^9.1.1",
|
|
60
|
-
"remeda": "^1.
|
|
76
|
+
"remeda": "^1.40.1",
|
|
61
77
|
"strip-indent": "^4.0.0",
|
|
62
|
-
"type-fest": "^4.
|
|
78
|
+
"type-fest": "^4.10.2",
|
|
63
79
|
"ufo": "^1.3.2",
|
|
64
80
|
"vscode-languageserver": "9.0.1",
|
|
65
81
|
"vscode-languageserver-protocol": "3.17.5",
|
|
66
82
|
"vscode-uri": "3.0.8"
|
|
67
83
|
},
|
|
68
84
|
"devDependencies": {
|
|
69
|
-
"@types/node": "^20.
|
|
85
|
+
"@types/node": "^20.11.17",
|
|
70
86
|
"@types/object-hash": "^3.0.6",
|
|
71
87
|
"execa": "^8.0.1",
|
|
72
88
|
"langium-cli": "^2.1.0",
|
|
73
|
-
"npm-run-
|
|
89
|
+
"npm-run-all2": "^5.0.2",
|
|
74
90
|
"typescript": "^5.3.3",
|
|
75
91
|
"unbuild": "^2.0.0",
|
|
76
|
-
"vitest": "^1.
|
|
92
|
+
"vitest": "^1.2.2"
|
|
77
93
|
},
|
|
78
|
-
"packageManager": "yarn@4.0
|
|
94
|
+
"packageManager": "yarn@4.1.0",
|
|
79
95
|
"volta": {
|
|
80
96
|
"extends": "../../package.json"
|
|
81
97
|
}
|