@likec4/language-server 1.46.4 → 1.47.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 +27 -21
- package/dist/LikeC4LanguageServices.js +24 -14
- package/dist/Rpc.js +7 -1
- package/dist/ast.d.ts +1 -1
- package/dist/browser.d.ts +0 -1
- package/dist/browser.js +0 -1
- package/dist/bundled.mjs +3769 -3597
- package/dist/filesystem/ChokidarWatcher.d.ts +3 -0
- package/dist/filesystem/ChokidarWatcher.js +67 -42
- package/dist/filesystem/LikeC4FileSystem.d.ts +1 -1
- package/dist/filesystem/LikeC4FileSystem.js +16 -6
- package/dist/generated/ast.d.ts +2 -2
- package/dist/generated/ast.js +1 -1
- package/dist/generated/grammar.js +1 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/lsp/CodeLensProvider.js +1 -1
- package/dist/lsp/CompletionProvider.d.ts +4 -2
- package/dist/lsp/CompletionProvider.js +41 -3
- package/dist/lsp/DocumentSymbolProvider.js +1 -1
- package/dist/lsp/SemanticTokenProvider.d.ts +8 -1
- package/dist/lsp/SemanticTokenProvider.js +52 -11
- package/dist/mcp/interfaces.d.ts +1 -1
- package/dist/mcp/interfaces.js +0 -1
- package/dist/mcp/server/StreamableLikeC4MCPServer.js +27 -51
- package/dist/mcp/tools/_common.d.ts +2 -2
- package/dist/mcp/tools/find-relationships.d.ts +195 -5
- package/dist/mcp/tools/list-projects.d.ts +191 -3
- package/dist/mcp/tools/open-view.d.ts +194 -4
- package/dist/mcp/tools/read-deployment.d.ts +194 -4
- package/dist/mcp/tools/read-element.d.ts +194 -4
- package/dist/mcp/tools/read-project-summary.d.ts +193 -3
- package/dist/mcp/tools/read-view.d.ts +194 -4
- package/dist/mcp/tools/search-element.d.ts +193 -3
- package/dist/model/model-builder.d.ts +4 -2
- package/dist/model/model-builder.js +56 -47
- package/dist/model/model-parser.d.ts +6 -6
- package/dist/model/parser/Base.js +58 -48
- package/dist/model/parser/GlobalsParser.d.ts +3 -3
- package/dist/model/parser/ViewsParser.js +2 -2
- package/dist/protocol.d.ts +5 -0
- package/dist/utils/elementRef.js +10 -4
- package/dist/validation/index.d.ts +1 -1
- package/dist/workspace/LangiumDocuments.d.ts +4 -0
- package/dist/workspace/LangiumDocuments.js +11 -5
- package/dist/workspace/ProjectsManager.d.ts +4 -0
- package/dist/workspace/ProjectsManager.js +89 -84
- package/package.json +16 -15
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { LikeC4ProjectConfig } from '@likec4/config';
|
|
2
|
-
import { type
|
|
2
|
+
import { type LayoutedView, type NonEmptyArray, type ProjectId, type UnknownComputed, type UnknownLayouted } from '@likec4/core';
|
|
3
|
+
import { type LayoutedProjectsView } from '@likec4/core/compute-view';
|
|
3
4
|
import { LikeC4Model } from '@likec4/core/model';
|
|
4
5
|
import { URI } from 'langium';
|
|
5
6
|
import type { CancellationToken } from 'vscode-jsonrpc';
|
|
@@ -27,8 +28,7 @@ export interface LikeC4LanguageServices {
|
|
|
27
28
|
config: Readonly<LikeC4ProjectConfig>;
|
|
28
29
|
}>;
|
|
29
30
|
/**
|
|
30
|
-
* Returns project by ID
|
|
31
|
-
* If no project ID is specified, returns default project
|
|
31
|
+
* Returns project by ID, returns default project if no ID is specified
|
|
32
32
|
*/
|
|
33
33
|
project(projectId?: ProjectId): {
|
|
34
34
|
id: ProjectId;
|
|
@@ -38,13 +38,31 @@ export interface LikeC4LanguageServices {
|
|
|
38
38
|
config: Readonly<LikeC4ProjectConfig>;
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
41
|
-
*
|
|
42
|
-
*
|
|
43
|
-
|
|
41
|
+
* Computes and layouts projects overview - a special diagram
|
|
42
|
+
* that shows all projects and their relationships
|
|
43
|
+
*/
|
|
44
|
+
projectsOverview(cancelToken?: CancellationToken): Promise<LayoutedProjectsView>;
|
|
45
|
+
/**
|
|
46
|
+
* Returns {@link LikeC4Model} of the specified project, with computed views {@link ComputedView}
|
|
47
|
+
* Not ready for rendering, but enough to traverse model. Much faster than {@link layoutedModel}
|
|
48
|
+
*
|
|
49
|
+
* If no {@link project} is specified, returns for default project
|
|
44
50
|
*/
|
|
45
|
-
diagrams(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<DiagramView[]>;
|
|
46
51
|
computedModel(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownComputed>>;
|
|
52
|
+
/**
|
|
53
|
+
* Returns {@link LikeC4Model} of the specified project, with layouted views {@link LayoutedView}
|
|
54
|
+
* Ready for rendering. Applies manual layouts if available.
|
|
55
|
+
*
|
|
56
|
+
* If no {@link project} is specified, returns for default project
|
|
57
|
+
*/
|
|
47
58
|
layoutedModel(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownLayouted>>;
|
|
59
|
+
/**
|
|
60
|
+
* Returns diagrams (i.e. layouted views {@link LayoutedView}) for the specified project
|
|
61
|
+
* Applies manual layouts if available.
|
|
62
|
+
*
|
|
63
|
+
* If no {@link project} is specified, returns diagrams for default project
|
|
64
|
+
*/
|
|
65
|
+
diagrams(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<LayoutedView[]>;
|
|
48
66
|
getErrors(): Array<{
|
|
49
67
|
message: string;
|
|
50
68
|
line: number;
|
|
@@ -82,22 +100,10 @@ export declare class DefaultLikeC4LanguageServices implements LikeC4LanguageServ
|
|
|
82
100
|
documents: ReadonlyArray<URI>;
|
|
83
101
|
config: LikeC4ProjectConfig;
|
|
84
102
|
};
|
|
85
|
-
|
|
86
|
-
* Diagram is a computed view, layouted using Graphviz
|
|
87
|
-
* If diagram has manual layout, it will be used.
|
|
88
|
-
*/
|
|
89
|
-
diagrams(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<DiagramView[]>;
|
|
90
|
-
/**
|
|
91
|
-
* Builds LikeC4Model from all documents
|
|
92
|
-
* Only computes view predicates {@link ComputedView} - i.e. no layout
|
|
93
|
-
* Not ready for rendering, but enough to traverse
|
|
94
|
-
*/
|
|
103
|
+
diagrams(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<LayoutedView<UnknownLayouted>[]>;
|
|
95
104
|
computedModel(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownComputed>>;
|
|
96
|
-
/**
|
|
97
|
-
* Same as {@link computedModel()}, but also applies layout
|
|
98
|
-
* Ready for rendering
|
|
99
|
-
*/
|
|
100
105
|
layoutedModel(project?: ProjectId | undefined, cancelToken?: CancellationToken): Promise<LikeC4Model<UnknownLayouted>>;
|
|
106
|
+
projectsOverview(cancelToken?: CancellationToken): Promise<LayoutedProjectsView>;
|
|
101
107
|
getErrors(): Array<{
|
|
102
108
|
message: string;
|
|
103
109
|
line: number;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { nonexhaustive, } from '@likec4/core';
|
|
2
|
+
import { computeProjectsView } from '@likec4/core/compute-view';
|
|
2
3
|
import { LikeC4Model } from '@likec4/core/model';
|
|
3
4
|
import { loggable } from '@likec4/log';
|
|
4
5
|
import { URI } from 'langium';
|
|
@@ -75,27 +76,14 @@ export class DefaultLikeC4LanguageServices {
|
|
|
75
76
|
config,
|
|
76
77
|
};
|
|
77
78
|
}
|
|
78
|
-
/**
|
|
79
|
-
* Diagram is a computed view, layouted using Graphviz
|
|
80
|
-
* If diagram has manual layout, it will be used.
|
|
81
|
-
*/
|
|
82
79
|
async diagrams(project, cancelToken) {
|
|
83
80
|
const projectId = this.projectsManager.ensureProjectId(project);
|
|
84
81
|
return await this.views.diagrams(projectId, cancelToken);
|
|
85
82
|
}
|
|
86
|
-
/**
|
|
87
|
-
* Builds LikeC4Model from all documents
|
|
88
|
-
* Only computes view predicates {@link ComputedView} - i.e. no layout
|
|
89
|
-
* Not ready for rendering, but enough to traverse
|
|
90
|
-
*/
|
|
91
83
|
async computedModel(project, cancelToken) {
|
|
92
84
|
const projectId = this.projectsManager.ensureProjectId(project);
|
|
93
85
|
return await this.builder.computeModel(projectId, cancelToken);
|
|
94
86
|
}
|
|
95
|
-
/**
|
|
96
|
-
* Same as {@link computedModel()}, but also applies layout
|
|
97
|
-
* Ready for rendering
|
|
98
|
-
*/
|
|
99
87
|
async layoutedModel(project, cancelToken) {
|
|
100
88
|
const projectId = this.projectsManager.ensureProjectId(project);
|
|
101
89
|
const model = await this.builder.computeModel(projectId, cancelToken);
|
|
@@ -109,6 +97,26 @@ export class DefaultLikeC4LanguageServices {
|
|
|
109
97
|
views: pipe(layouted, map(prop('diagram')), indexBy(prop('id'))),
|
|
110
98
|
});
|
|
111
99
|
}
|
|
100
|
+
async projectsOverview(cancelToken) {
|
|
101
|
+
const allProjects = this.services.shared.workspace.ProjectsManager.all;
|
|
102
|
+
const models = [];
|
|
103
|
+
for (const project of allProjects) {
|
|
104
|
+
const model = await this.builder.computeModel(project, cancelToken);
|
|
105
|
+
if (cancelToken?.isCancellationRequested) {
|
|
106
|
+
throw new Error('Operation cancelled');
|
|
107
|
+
}
|
|
108
|
+
if (model === LikeC4Model.EMPTY) {
|
|
109
|
+
logger.debug(`Project ${project} is empty, skipping`);
|
|
110
|
+
continue;
|
|
111
|
+
}
|
|
112
|
+
models.push(model);
|
|
113
|
+
}
|
|
114
|
+
if (!hasAtLeast(models, 1)) {
|
|
115
|
+
throw new Error('No models found');
|
|
116
|
+
}
|
|
117
|
+
const projectsView = computeProjectsView(models);
|
|
118
|
+
return await this.views.layouter.layoutProjectsView(projectsView);
|
|
119
|
+
}
|
|
112
120
|
getErrors() {
|
|
113
121
|
const docs = this.services.shared.workspace.LangiumDocuments.allExcludingBuiltin.toArray();
|
|
114
122
|
return docs.flatMap(doc => {
|
|
@@ -145,10 +153,12 @@ export class DefaultLikeC4LanguageServices {
|
|
|
145
153
|
}
|
|
146
154
|
this.services.Rpc.dispose();
|
|
147
155
|
this.services.likec4.ModelBuilder.dispose();
|
|
148
|
-
logger.debug('LikeC4LanguageServices disposed');
|
|
149
156
|
}
|
|
150
157
|
catch (e) {
|
|
151
158
|
logger.error(loggable(e));
|
|
152
159
|
}
|
|
160
|
+
finally {
|
|
161
|
+
logger.debug('LikeC4LanguageServices disposed');
|
|
162
|
+
}
|
|
153
163
|
}
|
|
154
164
|
}
|
package/dist/Rpc.js
CHANGED
|
@@ -112,7 +112,13 @@ export class Rpc extends ADisposable {
|
|
|
112
112
|
return;
|
|
113
113
|
}), connection.onRequest(RegisterProject.req, async (params, cancelToken) => {
|
|
114
114
|
logger.debug `received request ${'RegisterProject'}`;
|
|
115
|
-
|
|
115
|
+
let project;
|
|
116
|
+
if ('configUri' in params) {
|
|
117
|
+
project = await projects.registerConfigFile(URI.parse(params.configUri), cancelToken);
|
|
118
|
+
}
|
|
119
|
+
else {
|
|
120
|
+
project = await projects.registerProject(params, cancelToken);
|
|
121
|
+
}
|
|
116
122
|
return { id: project.id };
|
|
117
123
|
}), connection.onRequest(FetchViewsFromAllProjects.req, async (cancelToken) => {
|
|
118
124
|
logger.debug `received request ${'FetchViewsFromAllProjects'}`;
|
package/dist/ast.d.ts
CHANGED
|
@@ -173,7 +173,7 @@ export declare const ViewOps: {
|
|
|
173
173
|
readId(node: ast.LikeC4View): c4.ViewId | undefined;
|
|
174
174
|
};
|
|
175
175
|
export declare const ElementOps: {
|
|
176
|
-
writeId(node: ast.Element | ast.DeploymentElement, id: c4.Fqn | null): ast.
|
|
176
|
+
writeId(node: ast.Element | ast.DeploymentElement, id: c4.Fqn | null): ast.Element | ast.DeploymentElement;
|
|
177
177
|
readId(node: ast.Element | ast.DeploymentElement): c4.Fqn<string> | undefined;
|
|
178
178
|
};
|
|
179
179
|
export interface AstNodeDescriptionWithFqn extends AstNodeDescription {
|
package/dist/browser.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { type LikeC4Services, type LikeC4SharedServices } from './module';
|
|
2
|
-
export { logger as lspLogger } from './logger';
|
|
3
2
|
export type { DocumentParser, LikeC4ModelBuilder, LikeC4ModelLocator, LikeC4ModelParser } from './model';
|
|
4
3
|
export type { LikeC4LanguageServices } from './LikeC4LanguageServices';
|
|
5
4
|
export { createLanguageServices } from './module';
|
package/dist/browser.js
CHANGED
|
@@ -2,7 +2,6 @@ import { configureLogger, getConsoleSink, getTextFormatter } from '@likec4/log';
|
|
|
2
2
|
import { startLanguageServer as startLanguim } from 'langium/lsp';
|
|
3
3
|
import { BrowserMessageReader, BrowserMessageWriter, createConnection } from 'vscode-languageserver/browser';
|
|
4
4
|
import { createLanguageServices } from './module';
|
|
5
|
-
export { logger as lspLogger } from './logger';
|
|
6
5
|
export { createLanguageServices } from './module';
|
|
7
6
|
export function startLanguageServer(port) {
|
|
8
7
|
/* browser specific setup code */
|