From d3859056f2aad33ba01a25d7826fdedae2b96dd0 Mon Sep 17 00:00:00 2001 From: Abdelrahman Abounegm Date: Sun, 15 Sep 2024 14:04:03 +0300 Subject: [PATCH] Expose workspace folders via a readonly getter --- packages/langium/src/workspace/workspace-manager.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/langium/src/workspace/workspace-manager.ts b/packages/langium/src/workspace/workspace-manager.ts index c9619f61d..cdc9c7c4a 100644 --- a/packages/langium/src/workspace/workspace-manager.ts +++ b/packages/langium/src/workspace/workspace-manager.ts @@ -35,6 +35,12 @@ export interface WorkspaceManager { */ readonly ready: Promise; + /** + * 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. @@ -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; }