How to Handle Asynchronous Scoping #1308
-
I am working on a scope provider that will load an imported scope. It will do so by calling a remote endpoint via a network call and asking for the code in the imported package. It will then parse the package contents and provide the scope. The problem I'm seeing is that parsing is an asynchronous activity and the ScopeProvider interface expects a return type of Is there a recommended way to do this? |
Beta Was this translation helpful? Give feedback.
Replies: 3 comments 10 replies
-
After looking at this a bit further, it appears that all I need to do is obtain the
I assume that once I get this document, I can run validation on it to make sure it's valid. |
Beta Was this translation helpful? Give feedback.
-
Parsing is synchronous in Langium, but loading something from a remote resource likely isn't. How we usually do this (i.e. additional resources from something like a network resource), is by overriding the |
Beta Was this translation helpful? Give feedback.
-
@msujew, a couple of questions. Sorry for my lack of expertise here.
Also, my general design on this feature is to follow the methodology described in the docs here. I assume that this is the approach that would be recommended for my case, with the exception of how I retrieve the resource for reference from my remote endpoint. |
Beta Was this translation helpful? Give feedback.
An unresolved import points to a document (or multiple documents) that hasn't been loaded yet.
I've updated the code snippet above. There was a small error. It was supposed to be used for the
documentBuilder.update
call.