@likec4/language-server 1.38.0 → 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 +8 -0
- package/dist/LikeC4LanguageServices.js +25 -4
- package/dist/Rpc.js +11 -4
- 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 +3612 -3512
- 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 +3 -3
- 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/LangiumDocuments.d.ts +4 -1
- package/dist/workspace/LangiumDocuments.js +15 -0
- package/dist/workspace/ProjectsManager.d.ts +25 -11
- package/dist/workspace/ProjectsManager.js +85 -44
- package/dist/workspace/WorkspaceManager.js +5 -4
- package/package.json +22 -28
- 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,8 +1,9 @@
|
|
|
1
|
+
import { isLikeC4Config } from "@likec4/config/node";
|
|
1
2
|
import { loggable } from "@likec4/log";
|
|
2
3
|
import chokidar from "chokidar";
|
|
3
4
|
import { URI } from "langium";
|
|
4
5
|
import { logger as mainLogger } from "../logger.js";
|
|
5
|
-
import { isAnyLikeC4File
|
|
6
|
+
import { isAnyLikeC4File } from "./LikeC4FileSystem.js";
|
|
6
7
|
const logger = mainLogger.getChild("chokidar");
|
|
7
8
|
export const chokidarFileSystemWatcher = {
|
|
8
9
|
fileSystemWatcher: (services) => new ChokidarFileSystemWatcher(services)
|
|
@@ -18,7 +19,7 @@ export class ChokidarFileSystemWatcher {
|
|
|
18
19
|
} else {
|
|
19
20
|
this.watcher = this.createWatcher(folder);
|
|
20
21
|
}
|
|
21
|
-
logger.debug
|
|
22
|
+
logger.debug`watching folder: ${folder}`;
|
|
22
23
|
}
|
|
23
24
|
async dispose() {
|
|
24
25
|
if (this.watcher) {
|
|
@@ -29,16 +30,18 @@ export class ChokidarFileSystemWatcher {
|
|
|
29
30
|
}
|
|
30
31
|
createWatcher(folder) {
|
|
31
32
|
let watcher = chokidar.watch(folder, {
|
|
32
|
-
ignored: (path, stats) =>
|
|
33
|
+
ignored: (path, stats) => {
|
|
34
|
+
return path.includes("node_modules") || !!stats && stats.isFile() && !isAnyLikeC4File(path);
|
|
35
|
+
},
|
|
33
36
|
ignoreInitial: true
|
|
34
37
|
});
|
|
35
38
|
const onAddOrChange = async (path) => {
|
|
36
39
|
try {
|
|
37
|
-
if (
|
|
38
|
-
logger.debug
|
|
40
|
+
if (isLikeC4Config(path)) {
|
|
41
|
+
logger.debug`project file changed: ${path}`;
|
|
39
42
|
await this.services.workspace.ProjectsManager.reloadProjects();
|
|
40
43
|
} else {
|
|
41
|
-
logger.debug
|
|
44
|
+
logger.debug`file changed: ${path}`;
|
|
42
45
|
await this.services.workspace.DocumentBuilder.update([URI.file(path)], []);
|
|
43
46
|
}
|
|
44
47
|
} catch (error) {
|
|
@@ -47,11 +50,11 @@ export class ChokidarFileSystemWatcher {
|
|
|
47
50
|
};
|
|
48
51
|
const onRemove = async (path) => {
|
|
49
52
|
try {
|
|
50
|
-
if (
|
|
51
|
-
logger.debug
|
|
53
|
+
if (isLikeC4Config(path)) {
|
|
54
|
+
logger.debug`project file removed: ${path}`;
|
|
52
55
|
await this.services.workspace.ProjectsManager.reloadProjects();
|
|
53
56
|
} else {
|
|
54
|
-
logger.debug
|
|
57
|
+
logger.debug`file removed: ${path}`;
|
|
55
58
|
await this.services.workspace.DocumentBuilder.update([], [URI.file(path)]);
|
|
56
59
|
}
|
|
57
60
|
} catch (error) {
|
|
@@ -1,5 +1,3 @@
|
|
|
1
1
|
import type { FileSystemModuleContext } from './index';
|
|
2
2
|
export declare const LikeC4FileSystem: (ehableWatcher?: boolean) => FileSystemModuleContext;
|
|
3
|
-
export declare const isLikeC4ProjectFile: (path: string) => boolean;
|
|
4
|
-
export declare const isLikeC4File: (path: string) => any;
|
|
5
3
|
export declare const isAnyLikeC4File: (path: string) => any;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
+
import { isLikeC4Config, loadConfig } from "@likec4/config/node";
|
|
1
2
|
import { fdir } from "fdir";
|
|
2
3
|
import { URI } from "langium";
|
|
3
4
|
import { NodeFileSystemProvider } from "langium/node";
|
|
4
5
|
import { LikeC4LanguageMetaData } from "../generated/module.js";
|
|
5
6
|
import { Content, isLikeC4Builtin } from "../likec4lib.js";
|
|
6
7
|
import { logError } from "../logger.js";
|
|
7
|
-
import { ProjectsManager } from "../workspace/ProjectsManager.js";
|
|
8
8
|
import { chokidarFileSystemWatcher } from "./ChokidarWatcher.js";
|
|
9
9
|
import { noopFileSystemWatcher } from "./FileSystemWatcher.js";
|
|
10
10
|
export const LikeC4FileSystem = (ehableWatcher = true) => ({
|
|
11
11
|
fileSystemProvider: () => new SymLinkTraversingFileSystemProvider(),
|
|
12
12
|
...ehableWatcher ? chokidarFileSystemWatcher : noopFileSystemWatcher
|
|
13
13
|
});
|
|
14
|
-
|
|
15
|
-
export const
|
|
16
|
-
export const isAnyLikeC4File = (path) => isLikeC4File(path) || isLikeC4ProjectFile(path);
|
|
14
|
+
const isLikeC4File = (path) => LikeC4LanguageMetaData.fileExtensions.some((ext) => path.endsWith(ext));
|
|
15
|
+
export const isAnyLikeC4File = (path) => isLikeC4File(path) || isLikeC4Config(path);
|
|
17
16
|
class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
18
17
|
async readFile(uri) {
|
|
19
18
|
if (isLikeC4Builtin(uri)) {
|
|
@@ -40,7 +39,7 @@ class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
|
40
39
|
async scanProjectFiles(folderUri) {
|
|
41
40
|
const entries = [];
|
|
42
41
|
try {
|
|
43
|
-
const crawled = await new fdir().withSymlinks({ resolvePaths: false }).withFullPaths().filter(
|
|
42
|
+
const crawled = await new fdir().withSymlinks({ resolvePaths: false }).withFullPaths().filter(isLikeC4Config).crawl(folderUri.fsPath).withPromise();
|
|
44
43
|
for (const path of crawled) {
|
|
45
44
|
entries.push({
|
|
46
45
|
isFile: true,
|
|
@@ -53,4 +52,7 @@ class SymLinkTraversingFileSystemProvider extends NodeFileSystemProvider {
|
|
|
53
52
|
}
|
|
54
53
|
return entries;
|
|
55
54
|
}
|
|
55
|
+
async loadProjectConfig(filepath) {
|
|
56
|
+
return await loadConfig(filepath);
|
|
57
|
+
}
|
|
56
58
|
}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { type LikeC4ProjectConfig } from '@likec4/config';
|
|
1
2
|
import type { FileSystemNode, FileSystemProvider as LangiumFileSystemProvider, LangiumSharedCoreServices } from 'langium';
|
|
2
3
|
import { URI } from 'vscode-uri';
|
|
3
4
|
import { type FileSystemWatcherModuleContext } from './FileSystemWatcher';
|
|
@@ -8,6 +9,11 @@ export interface FileSystemProvider extends LangiumFileSystemProvider {
|
|
|
8
9
|
* @returns The list of file system entries that are contained within the specified directory.
|
|
9
10
|
*/
|
|
10
11
|
scanProjectFiles(folderUri: URI): Promise<FileSystemNode[]>;
|
|
12
|
+
/**
|
|
13
|
+
* Loads the project config from the given file.
|
|
14
|
+
* @returns The project config.
|
|
15
|
+
*/
|
|
16
|
+
loadProjectConfig(filepath: URI): Promise<LikeC4ProjectConfig>;
|
|
11
17
|
}
|
|
12
18
|
export interface FileSystemModuleContext extends FileSystemWatcherModuleContext {
|
|
13
19
|
fileSystemProvider: (services: LangiumSharedCoreServices) => FileSystemProvider;
|
|
@@ -16,5 +22,6 @@ export declare class NoopFileSystemProvider implements FileSystemProvider {
|
|
|
16
22
|
scanProjectFiles(): Promise<FileSystemNode[]>;
|
|
17
23
|
readFile(): Promise<string>;
|
|
18
24
|
readDirectory(): Promise<FileSystemNode[]>;
|
|
25
|
+
loadProjectConfig(): Promise<LikeC4ProjectConfig>;
|
|
19
26
|
}
|
|
20
27
|
export declare const NoopFileSystem: FileSystemModuleContext;
|
package/dist/filesystem/index.js
CHANGED
|
@@ -9,6 +9,9 @@ export class NoopFileSystemProvider {
|
|
|
9
9
|
readDirectory() {
|
|
10
10
|
return Promise.resolve([]);
|
|
11
11
|
}
|
|
12
|
+
loadProjectConfig() {
|
|
13
|
+
throw new Error("No file system is available.");
|
|
14
|
+
}
|
|
12
15
|
}
|
|
13
16
|
export const NoopFileSystem = {
|
|
14
17
|
fileSystemProvider: () => new NoopFileSystemProvider(),
|
package/dist/generated/ast.d.ts
CHANGED
package/dist/generated/ast.js
CHANGED
|
@@ -8,6 +8,7 @@ export const LikeC4Terminals = {
|
|
|
8
8
|
LIB_ICON: /(aws|azure|gcp|tech):[-\w]*/,
|
|
9
9
|
URI_WITH_SCHEMA: /\w+:\/{2}\S+/,
|
|
10
10
|
URI_RELATIVE: /\.{0,2}\/[^\/]\S+/,
|
|
11
|
+
URI_ALIAS: /@[a-zA-Z0-9_-]*\/[^\s]+/,
|
|
11
12
|
DotUnderscore: /\b\._(?![_a-zA-Z])/,
|
|
12
13
|
DotWildcard: /\b\.\*{1,2}/,
|
|
13
14
|
Hash: /#/,
|
|
@@ -150,7 +151,7 @@ export function isThemeColor(item) {
|
|
|
150
151
|
return item === "primary" || item === "secondary" || item === "muted" || item === "slate" || item === "blue" || item === "indigo" || item === "sky" || item === "red" || item === "gray" || item === "green" || item === "amber";
|
|
151
152
|
}
|
|
152
153
|
export function isUri(item) {
|
|
153
|
-
return typeof item === "string" && (/\w+:\/{2}\S+/.test(item) || /\.{0,2}\/[^\/]\S+/.test(item));
|
|
154
|
+
return typeof item === "string" && (/\w+:\/{2}\S+/.test(item) || /\.{0,2}\/[^\/]\S+/.test(item) || /@[a-zA-Z0-9_-]*\/[^\s]+/.test(item));
|
|
154
155
|
}
|
|
155
156
|
export function isViewLayoutDirection(item) {
|
|
156
157
|
return item === "TopBottom" || item === "LeftRight" || item === "BottomTop" || item === "RightLeft";
|