How can I get the "root" directory inside a ScopeProvider? #1775
-
Hallo, I implement a custom ScopeProvider which uses the DefaultScopeProvider as a base and override the getGlobalScope with custom logic. I need a way to get the current "root" directory of the files (when they are edited inside VS Code), but I can't find any API to get this information. I tried to google and asked some chat bots, but they all gave me answers with an outdated API. I have access to the LangiumCoreServices, which has access to TextDocumentProvider, WorkspaceManager, FileSystemProvider, LangiumDocuments and many other things but I checked all of them and couldn't find any functions which would give me the root directory. Additional info: |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 8 replies
-
maybe calling |
Beta Was this translation helpful? Give feedback.
-
I am having the same requirement. The approach that I take is to call het getScope(...) from the DefaultScopeProvider and then filter it with only the items that come from a file in the same directory as where I an asking the scope for. I can get the uri's of all elements involved, so this works fine in many cases, except for the following. If I have two nodes with identical names in files in two different folders, the default scoper does not return both nodes, which is what I expected. I could then filter the one I need. However, the default scoper only returns one of the identical named nodes, and if that is the one not from a file in the current folder, I won't see the one from the current folder. Therefore it seems I need to dive deeper into the scoping calculation. I could either
Any help would be appreciated. |
Beta Was this translation helpful? Give feedback.
maybe calling
serivces.shared.workspace.WorkspaceManager.workspaceFolders()
does the trick