Skip to content

Commit 9a95935

Browse files
committed
fix: add option to not exclude imports in loadDocument
1 parent 8230b9c commit 9a95935

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/language/src/index.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class DocumentLoadError extends Error {
2121
export async function loadDocument(
2222
fileName: string,
2323
pluginModelFiles: string[] = [],
24+
keepImports: boolean = false,
2425
): Promise<
2526
{ success: true; model: Model; warnings: string[], services: ZModelServices } | { success: false; errors: string[]; warnings: string[] }
2627
> {
@@ -109,14 +110,17 @@ export async function loadDocument(
109110

110111
const model = document.parseResult.value as Model;
111112

112-
// merge all declarations into the main document
113-
const imported = mergeImportsDeclarations(langiumDocuments, model);
113+
if (keepImports === false) {
114+
115+
// merge all declarations into the main document
116+
const imported = mergeImportsDeclarations(langiumDocuments, model);
114117

115118
// remove imported documents
116119
imported.forEach((model) => {
117-
langiumDocuments.deleteDocument(model.$document!.uri);
118-
services.shared.workspace.IndexManager.remove(model.$document!.uri);
119-
});
120+
langiumDocuments.deleteDocument(model.$document!.uri);
121+
services.shared.workspace.IndexManager.remove(model.$document!.uri);
122+
});
123+
}
120124

121125
// extra validation after merging imported declarations
122126
const additionalErrors = validationAfterImportMerge(model);

0 commit comments

Comments
 (0)