@likec4/language-server 1.28.0 → 1.29.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.
@@ -4,11 +4,14 @@ import { type Range } from 'vscode-languageserver-types';
4
4
  import type { ProjectConfig } from './config';
5
5
  import type { LikeC4ModelBuilder } from './model';
6
6
  import type { LikeC4Services } from './module';
7
+ import type { Locate } from './protocol';
7
8
  import type { LikeC4Views } from './views/likec4-views';
9
+ import { ProjectsManager } from './workspace';
8
10
  export interface LikeC4LanguageServices {
9
11
  readonly views: LikeC4Views;
10
12
  readonly builder: LikeC4ModelBuilder;
11
13
  readonly workspaceUri: URI;
14
+ readonly projectsManager: ProjectsManager;
12
15
  projects(): NonEmptyArray<{
13
16
  id: ProjectId;
14
17
  folder: URI;
@@ -28,6 +31,7 @@ export interface LikeC4LanguageServices {
28
31
  changed?: string;
29
32
  removed?: string;
30
33
  }): Promise<boolean>;
34
+ locate(params: Locate.Params): Locate.Res;
31
35
  }
32
36
  /**
33
37
  * Public Language Services
@@ -36,7 +40,7 @@ export declare class DefaultLikeC4LanguageServices implements LikeC4LanguageServ
36
40
  private services;
37
41
  readonly views: LikeC4Views;
38
42
  readonly builder: LikeC4ModelBuilder;
39
- private projectsManager;
43
+ readonly projectsManager: ProjectsManager;
40
44
  constructor(services: LikeC4Services);
41
45
  get workspaceUri(): URI;
42
46
  projects(): NonEmptyArray<{
@@ -74,4 +78,5 @@ export declare class DefaultLikeC4LanguageServices implements LikeC4LanguageServ
74
78
  changed?: string;
75
79
  removed?: string;
76
80
  }): Promise<boolean>;
81
+ locate(params: Locate.Params): Locate.Res;
77
82
  }
@@ -1,4 +1,4 @@
1
- import { LikeC4Model } from "@likec4/core";
1
+ import { LikeC4Model, nonexhaustive } from "@likec4/core";
2
2
  import { loggable } from "@likec4/log";
3
3
  import { URI } from "langium";
4
4
  import { entries, hasAtLeast, indexBy, map, pipe, prop } from "remeda";
@@ -114,4 +114,21 @@ export class DefaultLikeC4LanguageServices {
114
114
  return false;
115
115
  }
116
116
  }
117
+ locate(params) {
118
+ switch (true) {
119
+ case "element" in params:
120
+ return this.services.likec4.ModelLocator.locateElement(params.element, params.projectId);
121
+ case "relation" in params:
122
+ return this.services.likec4.ModelLocator.locateRelation(params.relation, params.projectId);
123
+ case "view" in params:
124
+ return this.services.likec4.ModelLocator.locateView(params.view, params.projectId);
125
+ case "deployment" in params:
126
+ return this.services.likec4.ModelLocator.locateDeploymentElement(
127
+ params.deployment,
128
+ params.projectId
129
+ );
130
+ default:
131
+ nonexhaustive(params);
132
+ }
133
+ }
117
134
  }