Skip to content

How do I load all documents in a (nested) directory structure #1778

Answered by msujew
BaukeL asked this question in Q&A
Discussion options

You must be logged in to vote

Hey @BaukeL,

there are two ways to go about this:

  1. As you've outlined, iterate through all the files in a directory via the fs import and create documents for all of them and pass them into the DocumentBuilder.build method.
  2. Use the WorkspaceManager#initializeWorkspace method and pass in an array of WorkspaceFolder. It calls DocumentBuilder.build internally. See:
    export async function setRootFolder(fileName: string, services: LangiumCoreServices, root?: string): Promise<void> {
    if (!root) {
    root = path.dirname(fileName);
    }
    if (!path.isAbsolute(root)) {
    root = path.resolve(process.c…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by BaukeL
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants