Skip to content

Commit

Permalink
Expose workspace folders via a readonly getter (#1679)
Browse files Browse the repository at this point in the history
  • Loading branch information
aabounegm authored Sep 15, 2024
1 parent b2a6fe9 commit 335f9a9
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions packages/langium/src/workspace/workspace-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ export interface WorkspaceManager {
*/
readonly ready: Promise<void>;

/**
* The workspace folders of the current workspace.
* Available only after the `ready` promise resolves.
*/
get workspaceFolders(): readonly WorkspaceFolder[] | undefined;

/**
* When used in a language server context, this method is called when the server receives
* the `initialize` request.
Expand Down Expand Up @@ -85,6 +91,10 @@ export class DefaultWorkspaceManager implements WorkspaceManager {
return this._ready.promise;
}

get workspaceFolders(): readonly WorkspaceFolder[] | undefined {
return this.folders;
}

initialize(params: InitializeParams): void {
this.folders = params.workspaceFolders ?? undefined;
}
Expand Down

0 comments on commit 335f9a9

Please sign in to comment.