@likec4/language-server 1.38.1 → 1.39.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.d.ts +7 -0
- package/dist/LikeC4LanguageServices.js +25 -4
- package/dist/Rpc.js +9 -2
- package/dist/ast.d.ts +1 -1
- package/dist/ast.js +2 -1
- package/dist/bundled.d.ts +8 -0
- package/dist/bundled.js +40 -0
- package/dist/bundled.mjs +3629 -3523
- package/dist/filesystem/ChokidarWatcher.js +12 -9
- package/dist/filesystem/LikeC4FileSystem.d.ts +0 -2
- package/dist/filesystem/LikeC4FileSystem.js +7 -5
- package/dist/filesystem/index.d.ts +7 -0
- package/dist/filesystem/index.js +3 -0
- package/dist/generated/ast.d.ts +1 -0
- package/dist/generated/ast.js +2 -1
- package/dist/generated/grammar.js +1 -1
- package/dist/generated-lib/icons.js +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/logger.js +1 -1
- package/dist/mcp/MCPServerFactory.js +6 -5
- package/dist/mcp/server/StreamableLikeC4MCPServer.d.ts +2 -2
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +97 -100
- package/dist/mcp/server/WithMCPServer.d.ts +3 -1
- package/dist/mcp/server/WithMCPServer.js +6 -5
- package/dist/mcp/tools/search-element.js +26 -11
- package/dist/mcp/utils.js +2 -2
- package/dist/model/builder/MergedSpecification.d.ts +2 -2
- package/dist/model/builder/MergedSpecification.js +4 -7
- package/dist/model/builder/assignTagColors.js +1 -1
- package/dist/model/builder/buildModel.d.ts +3 -8
- package/dist/model/builder/buildModel.js +14 -11
- package/dist/model/model-builder.d.ts +1 -1
- package/dist/model/model-locator.js +2 -1
- package/dist/model/model-parser.d.ts +19 -46
- package/dist/model/model-parser.js +13 -3
- package/dist/model/parser/Base.d.ts +4 -7
- package/dist/model/parser/Base.js +19 -0
- package/dist/model/parser/DeploymentModelParser.d.ts +2 -5
- package/dist/model/parser/DeploymentViewParser.d.ts +2 -5
- package/dist/model/parser/FqnRefParser.d.ts +2 -5
- package/dist/model/parser/GlobalsParser.d.ts +2 -5
- package/dist/model/parser/ImportsParser.d.ts +2 -5
- package/dist/model/parser/ModelParser.d.ts +2 -5
- package/dist/model/parser/PredicatesParser.d.ts +2 -5
- package/dist/model/parser/SpecificationParser.d.ts +2 -5
- package/dist/model/parser/ViewsParser.d.ts +2 -5
- package/dist/protocol.d.ts +16 -2
- package/dist/protocol.js +4 -0
- package/dist/test/testServices.d.ts +5 -1
- package/dist/test/testServices.js +18 -3
- package/dist/utils/disposable.d.ts +1 -1
- package/dist/utils/stringHash.js +1 -1
- package/dist/view-utils/resolve-relative-paths.js +1 -1
- package/dist/workspace/ProjectsManager.d.ts +24 -10
- package/dist/workspace/ProjectsManager.js +72 -27
- package/dist/workspace/WorkspaceManager.js +5 -4
- package/package.json +20 -26
- package/dist/config/index.d.ts +0 -1
- package/dist/config/index.js +0 -1
- package/dist/config/schema.d.ts +0 -10
- package/dist/config/schema.js +0 -39
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { LikeC4ProjectConfig } from '@likec4/config';
|
|
1
2
|
import { type DiagramView, type NonEmptyArray, type ProjectId } from '@likec4/core';
|
|
2
3
|
import { LikeC4Model } from '@likec4/core/model';
|
|
3
4
|
import { type LangiumDocument, URI } from 'langium';
|
|
@@ -20,6 +21,7 @@ export interface LikeC4LanguageServices {
|
|
|
20
21
|
folder: URI;
|
|
21
22
|
title: string;
|
|
22
23
|
documents: ReadonlyArray<URI>;
|
|
24
|
+
config: Readonly<LikeC4ProjectConfig>;
|
|
23
25
|
}>;
|
|
24
26
|
/**
|
|
25
27
|
* Returns project by ID
|
|
@@ -30,6 +32,7 @@ export interface LikeC4LanguageServices {
|
|
|
30
32
|
folder: URI;
|
|
31
33
|
title: string;
|
|
32
34
|
documents: ReadonlyArray<URI>;
|
|
35
|
+
config: Readonly<LikeC4ProjectConfig>;
|
|
33
36
|
};
|
|
34
37
|
/**
|
|
35
38
|
* Returns diagrams (i.e. views with layout computed) for the specified project
|
|
@@ -60,6 +63,7 @@ export interface LikeC4LanguageServices {
|
|
|
60
63
|
* Checks if the specified document should be excluded from processing.
|
|
61
64
|
*/
|
|
62
65
|
isExcluded(doc: LangiumDocument): boolean;
|
|
66
|
+
dispose(): Promise<void>;
|
|
63
67
|
}
|
|
64
68
|
/**
|
|
65
69
|
* Public Language Services
|
|
@@ -76,12 +80,14 @@ export declare class DefaultLikeC4LanguageServices implements LikeC4LanguageServ
|
|
|
76
80
|
folder: URI;
|
|
77
81
|
title: string;
|
|
78
82
|
documents: ReadonlyArray<URI>;
|
|
83
|
+
config: LikeC4ProjectConfig;
|
|
79
84
|
}>;
|
|
80
85
|
project(projectId?: ProjectId): {
|
|
81
86
|
id: ProjectId;
|
|
82
87
|
folder: URI;
|
|
83
88
|
title: string;
|
|
84
89
|
documents: ReadonlyArray<URI>;
|
|
90
|
+
config: LikeC4ProjectConfig;
|
|
85
91
|
};
|
|
86
92
|
/**
|
|
87
93
|
* Diagram is a computed view, layouted using Graphviz
|
|
@@ -117,4 +123,5 @@ export declare class DefaultLikeC4LanguageServices implements LikeC4LanguageServ
|
|
|
117
123
|
* Checks if the specified document should be excluded from processing.
|
|
118
124
|
*/
|
|
119
125
|
isExcluded(doc: LangiumDocument): boolean;
|
|
126
|
+
dispose(): Promise<void>;
|
|
120
127
|
}
|
|
@@ -9,7 +9,7 @@ import { DiagnosticSeverity } from "vscode-languageserver-types";
|
|
|
9
9
|
import { isLikeC4LangiumDocument } from "./ast.js";
|
|
10
10
|
import { logger as mainLogger, logWarnError } from "./logger.js";
|
|
11
11
|
import { ProjectsManager } from "./workspace/index.js";
|
|
12
|
-
const logger = mainLogger.getChild("
|
|
12
|
+
const logger = mainLogger.getChild("LanguageServices");
|
|
13
13
|
export class DefaultLikeC4LanguageServices {
|
|
14
14
|
constructor(services) {
|
|
15
15
|
this.services = services;
|
|
@@ -35,10 +35,19 @@ export class DefaultLikeC4LanguageServices {
|
|
|
35
35
|
id,
|
|
36
36
|
folder: folderUri2,
|
|
37
37
|
title: config2.title ?? config2.name,
|
|
38
|
-
documents: map(docs, prop("uri"))
|
|
38
|
+
documents: map(docs, prop("uri")),
|
|
39
|
+
config: config2
|
|
39
40
|
};
|
|
40
41
|
})
|
|
41
42
|
);
|
|
43
|
+
if (hasAtLeast(projectsWithDocs, 2) && projectsManager.defaultProjectId) {
|
|
44
|
+
const idx = projectsWithDocs.findIndex((p) => p.id === projectsManager.defaultProjectId);
|
|
45
|
+
if (idx > 0) {
|
|
46
|
+
const [defaultProject] = projectsWithDocs.splice(idx, 1);
|
|
47
|
+
return [defaultProject, ...projectsWithDocs];
|
|
48
|
+
}
|
|
49
|
+
return projectsWithDocs;
|
|
50
|
+
}
|
|
42
51
|
if (hasAtLeast(projectsWithDocs, 1)) {
|
|
43
52
|
return projectsWithDocs;
|
|
44
53
|
}
|
|
@@ -51,7 +60,8 @@ export class DefaultLikeC4LanguageServices {
|
|
|
51
60
|
id: ProjectsManager.DefaultProjectId,
|
|
52
61
|
folder: folderUri,
|
|
53
62
|
title: config.title ?? config.name,
|
|
54
|
-
documents
|
|
63
|
+
documents,
|
|
64
|
+
config
|
|
55
65
|
}];
|
|
56
66
|
}
|
|
57
67
|
project(projectId) {
|
|
@@ -66,7 +76,8 @@ export class DefaultLikeC4LanguageServices {
|
|
|
66
76
|
id: projectId,
|
|
67
77
|
folder: folderUri,
|
|
68
78
|
title: config.title ?? config.name,
|
|
69
|
-
documents
|
|
79
|
+
documents,
|
|
80
|
+
config
|
|
70
81
|
};
|
|
71
82
|
}
|
|
72
83
|
/**
|
|
@@ -172,4 +183,14 @@ export class DefaultLikeC4LanguageServices {
|
|
|
172
183
|
return false;
|
|
173
184
|
}
|
|
174
185
|
}
|
|
186
|
+
async dispose() {
|
|
187
|
+
logger.debug("disposing LikeC4LanguageServices");
|
|
188
|
+
await this.services.shared.workspace.FileSystemWatcher.dispose();
|
|
189
|
+
if (this.services.mcp.Server.isStarted) {
|
|
190
|
+
await this.services.mcp.Server.stop();
|
|
191
|
+
}
|
|
192
|
+
this.services.Rpc.dispose();
|
|
193
|
+
this.services.likec4.ModelBuilder.dispose();
|
|
194
|
+
logger.debug("LikeC4LanguageServices disposed");
|
|
195
|
+
}
|
|
175
196
|
}
|
package/dist/Rpc.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { filter, flatMap, funnel, indexBy, keys, map, mapValues, pipe, sort } from "remeda";
|
|
2
2
|
import { logger as rootLogger } from "./logger.js";
|
|
3
|
+
import { serializableLikeC4ProjectConfig } from "@likec4/config";
|
|
3
4
|
import {
|
|
4
5
|
nonexhaustive
|
|
5
6
|
} from "@likec4/core";
|
|
@@ -20,6 +21,7 @@ import {
|
|
|
20
21
|
GetDocumentTags,
|
|
21
22
|
LayoutView,
|
|
22
23
|
Locate,
|
|
24
|
+
RegisterProject,
|
|
23
25
|
ReloadProjects,
|
|
24
26
|
ValidateLayout
|
|
25
27
|
} from "./protocol.js";
|
|
@@ -114,7 +116,7 @@ export class Rpc extends ADisposable {
|
|
|
114
116
|
} = projects.getProject(projectId);
|
|
115
117
|
return {
|
|
116
118
|
folder: folderUri.toString(),
|
|
117
|
-
config,
|
|
119
|
+
config: serializableLikeC4ProjectConfig(config),
|
|
118
120
|
docs: map(docs, (d) => d.uri.toString())
|
|
119
121
|
};
|
|
120
122
|
})
|
|
@@ -125,6 +127,11 @@ export class Rpc extends ADisposable {
|
|
|
125
127
|
await projects.reloadProjects(cancelToken);
|
|
126
128
|
return;
|
|
127
129
|
}),
|
|
130
|
+
connection.onRequest(RegisterProject.req, async (params) => {
|
|
131
|
+
logger.debug`received request ${"RegisterProject"}`;
|
|
132
|
+
const project = await projects.registerProject(params);
|
|
133
|
+
return { id: project.id };
|
|
134
|
+
}),
|
|
128
135
|
connection.onRequest(FetchViewsFromAllProjects.req, async (cancelToken) => {
|
|
129
136
|
logger.debug`received request ${"FetchViewsFromAllProjects"}`;
|
|
130
137
|
const promises = projects.all.map(async (projectId) => {
|
|
@@ -272,7 +279,7 @@ export class Rpc extends ADisposable {
|
|
|
272
279
|
async openView(params) {
|
|
273
280
|
const lspConnection = this.services.shared.lsp.Connection;
|
|
274
281
|
if (!lspConnection) {
|
|
275
|
-
logger.
|
|
282
|
+
logger.warn("No LSP connection");
|
|
276
283
|
return;
|
|
277
284
|
}
|
|
278
285
|
await lspConnection.sendNotification(
|
package/dist/ast.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type * as c4 from '@likec4/core';
|
|
2
|
-
import { MultiMap } from '@likec4/core';
|
|
2
|
+
import { MultiMap } from '@likec4/core/utils';
|
|
3
3
|
import type { AstNode, AstNodeDescription, DiagnosticInfo, LangiumDocument } from 'langium';
|
|
4
4
|
import type { ConditionalPick, MergeExclusive, Simplify, ValueOf, Writable } from 'type-fest';
|
|
5
5
|
import type { Diagnostic } from 'vscode-languageserver-types';
|
package/dist/ast.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor
|
|
1
|
+
import { DefaultArrowType, DefaultLineStyle, DefaultRelationshipColor } from "@likec4/core";
|
|
2
|
+
import { nonexhaustive } from "@likec4/core/utils";
|
|
2
3
|
import { AstUtils, DocumentState } from "langium";
|
|
3
4
|
import { clamp, isNullish, isTruthy } from "remeda";
|
|
4
5
|
import * as ast from "./generated/ast.js";
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type LikeC4Services, type LikeC4SharedServices } from './module';
|
|
2
|
+
/**
|
|
3
|
+
* This is used as `bin` entry point to start the language server.
|
|
4
|
+
*/
|
|
5
|
+
export declare function startLanguageServer(): {
|
|
6
|
+
shared: LikeC4SharedServices;
|
|
7
|
+
likec4: LikeC4Services;
|
|
8
|
+
};
|
package/dist/bundled.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { configureLogger, getConsoleStderrSink } from "@likec4/log";
|
|
2
|
+
import { startLanguageServer as startLanguim } from "langium/lsp";
|
|
3
|
+
import { createConnection, ProposedFeatures } from "vscode-languageserver/node";
|
|
4
|
+
import { LikeC4FileSystem } from "./filesystem/LikeC4FileSystem.js";
|
|
5
|
+
import { getLspConnectionSink, logger } from "./logger.js";
|
|
6
|
+
import { WithMCPServer } from "./mcp/server/WithMCPServer.js";
|
|
7
|
+
import { createLanguageServices } from "./module.js";
|
|
8
|
+
import { ConfigurableLayouter } from "./views/configurable-layouter.js";
|
|
9
|
+
export function startLanguageServer() {
|
|
10
|
+
const connection = createConnection(ProposedFeatures.all);
|
|
11
|
+
configureLogger({
|
|
12
|
+
sinks: {
|
|
13
|
+
// Name it as console to override internal logger
|
|
14
|
+
lsp: getLspConnectionSink(connection),
|
|
15
|
+
console: getConsoleStderrSink()
|
|
16
|
+
},
|
|
17
|
+
loggers: [
|
|
18
|
+
{
|
|
19
|
+
category: ["likec4"],
|
|
20
|
+
sinks: ["console", "lsp"]
|
|
21
|
+
}
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
process.on("uncaughtException", (err) => {
|
|
25
|
+
logger.error("uncaughtException", { err });
|
|
26
|
+
});
|
|
27
|
+
process.on("unhandledRejection", (err) => {
|
|
28
|
+
logger.error("unhandledRejection", { err });
|
|
29
|
+
});
|
|
30
|
+
const services = createLanguageServices(
|
|
31
|
+
{
|
|
32
|
+
connection,
|
|
33
|
+
...LikeC4FileSystem(false),
|
|
34
|
+
...WithMCPServer("sse")
|
|
35
|
+
},
|
|
36
|
+
ConfigurableLayouter
|
|
37
|
+
);
|
|
38
|
+
startLanguim(services.shared);
|
|
39
|
+
return services;
|
|
40
|
+
}
|