@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.
Files changed (61) hide show
  1. package/dist/LikeC4LanguageServices.d.ts +7 -0
  2. package/dist/LikeC4LanguageServices.js +25 -4
  3. package/dist/Rpc.js +9 -2
  4. package/dist/ast.d.ts +1 -1
  5. package/dist/ast.js +2 -1
  6. package/dist/bundled.d.ts +8 -0
  7. package/dist/bundled.js +40 -0
  8. package/dist/bundled.mjs +3629 -3523
  9. package/dist/filesystem/ChokidarWatcher.js +12 -9
  10. package/dist/filesystem/LikeC4FileSystem.d.ts +0 -2
  11. package/dist/filesystem/LikeC4FileSystem.js +7 -5
  12. package/dist/filesystem/index.d.ts +7 -0
  13. package/dist/filesystem/index.js +3 -0
  14. package/dist/generated/ast.d.ts +1 -0
  15. package/dist/generated/ast.js +2 -1
  16. package/dist/generated/grammar.js +1 -1
  17. package/dist/generated-lib/icons.js +1 -1
  18. package/dist/index.d.ts +1 -0
  19. package/dist/logger.js +1 -1
  20. package/dist/mcp/MCPServerFactory.js +6 -5
  21. package/dist/mcp/server/StreamableLikeC4MCPServer.d.ts +2 -2
  22. package/dist/mcp/server/StreamableLikeC4MCPServer.js +97 -100
  23. package/dist/mcp/server/WithMCPServer.d.ts +3 -1
  24. package/dist/mcp/server/WithMCPServer.js +6 -5
  25. package/dist/mcp/tools/search-element.js +26 -11
  26. package/dist/mcp/utils.js +2 -2
  27. package/dist/model/builder/MergedSpecification.d.ts +2 -2
  28. package/dist/model/builder/MergedSpecification.js +4 -7
  29. package/dist/model/builder/assignTagColors.js +1 -1
  30. package/dist/model/builder/buildModel.d.ts +3 -8
  31. package/dist/model/builder/buildModel.js +14 -11
  32. package/dist/model/model-builder.d.ts +1 -1
  33. package/dist/model/model-locator.js +2 -1
  34. package/dist/model/model-parser.d.ts +19 -46
  35. package/dist/model/model-parser.js +13 -3
  36. package/dist/model/parser/Base.d.ts +4 -7
  37. package/dist/model/parser/Base.js +19 -0
  38. package/dist/model/parser/DeploymentModelParser.d.ts +2 -5
  39. package/dist/model/parser/DeploymentViewParser.d.ts +2 -5
  40. package/dist/model/parser/FqnRefParser.d.ts +2 -5
  41. package/dist/model/parser/GlobalsParser.d.ts +2 -5
  42. package/dist/model/parser/ImportsParser.d.ts +2 -5
  43. package/dist/model/parser/ModelParser.d.ts +2 -5
  44. package/dist/model/parser/PredicatesParser.d.ts +2 -5
  45. package/dist/model/parser/SpecificationParser.d.ts +2 -5
  46. package/dist/model/parser/ViewsParser.d.ts +2 -5
  47. package/dist/protocol.d.ts +16 -2
  48. package/dist/protocol.js +4 -0
  49. package/dist/test/testServices.d.ts +5 -1
  50. package/dist/test/testServices.js +18 -3
  51. package/dist/utils/disposable.d.ts +1 -1
  52. package/dist/utils/stringHash.js +1 -1
  53. package/dist/view-utils/resolve-relative-paths.js +1 -1
  54. package/dist/workspace/ProjectsManager.d.ts +24 -10
  55. package/dist/workspace/ProjectsManager.js +72 -27
  56. package/dist/workspace/WorkspaceManager.js +5 -4
  57. package/package.json +20 -26
  58. package/dist/config/index.d.ts +0 -1
  59. package/dist/config/index.js +0 -1
  60. package/dist/config/schema.d.ts +0 -10
  61. 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, isLikeC4ProjectFile } from "./LikeC4FileSystem.js";
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(`watching folder: ${folder}`);
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) => path.includes("node_modules") || !!stats && stats.isFile() && !isAnyLikeC4File(path),
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 (isLikeC4ProjectFile(path)) {
38
- logger.debug(`project file changed: ${path}`);
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(`file changed: ${path}`);
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 (isLikeC4ProjectFile(path)) {
51
- logger.debug(`project file removed: ${path}`);
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(`file removed: ${path}`);
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
- export const isLikeC4ProjectFile = (path) => ProjectsManager.ConfigFileNames.some((ext) => path.endsWith(ext));
15
- export const isLikeC4File = (path) => LikeC4LanguageMetaData.fileExtensions.some((ext) => path.endsWith(ext));
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(isLikeC4ProjectFile).crawl(folderUri.fsPath).withPromise();
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;
@@ -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(),
@@ -12,6 +12,7 @@ export declare const LikeC4Terminals: {
12
12
  LIB_ICON: RegExp;
13
13
  URI_WITH_SCHEMA: RegExp;
14
14
  URI_RELATIVE: RegExp;
15
+ URI_ALIAS: RegExp;
15
16
  DotUnderscore: RegExp;
16
17
  DotWildcard: RegExp;
17
18
  Hash: RegExp;
@@ -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";