Skip to content

Commit 8fa5b89

Browse files
authored
move initial document loading into an overrideable method (#2083)
* move initial document loading into an overrideable method * review feedback
1 parent 5da26fc commit 8fa5b89

File tree

1 file changed

+8
-5
lines changed

1 file changed

+8
-5
lines changed

packages/langium/src/workspace/workspace-manager.ts

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ import type { BuildOptions, DocumentBuilder } from './document-builder.js';
1515
import type { LangiumDocument, LangiumDocuments } from './documents.js';
1616
import type { FileSystemNode, FileSystemProvider } from './file-system-provider.js';
1717
import type { WorkspaceLock } from './workspace-lock.js';
18-
import { stream } from '../utils/stream.js';
19-
18+
import { stream, type Stream } from '../utils/stream.js';
2019
// export type WorkspaceFolder from 'vscode-languageserver-types' for convenience,
2120
// is supposed to avoid confusion as 'WorkspaceFolder' might accidentally be imported via 'vscode-languageclient'
2221
export type { WorkspaceFolder };
@@ -164,12 +163,16 @@ export class DefaultWorkspaceManager implements WorkspaceManager {
164163
.distinct(uri => uri.toString())
165164
// Also ensure that the documents don't already exist
166165
.filter(uri => !this.langiumDocuments.hasDocument(uri));
167-
await Promise.all(uniqueUris.map(async uri => {
166+
await this.loadWorkspaceDocuments(uniqueUris, collector);
167+
this._ready.resolve();
168+
return documents;
169+
}
170+
171+
protected async loadWorkspaceDocuments(uris: Stream<URI>, collector: (document: LangiumDocument) => void): Promise<void> {
172+
await Promise.all(uris.map(async uri => {
168173
const document = await this.langiumDocuments.getOrCreateDocument(uri);
169174
collector(document);
170175
}));
171-
this._ready.resolve();
172-
return documents;
173176
}
174177

175178
/**

0 commit comments

Comments
 (0)