Closed georg-schwarz closed 2 weeks ago
Hey @georg-schwarz,
The decision to make the getScope
method sync was very deliberate, as otherwise every reference resolution, i.e. every call to ref
becomes async.
There are other ways of solving this, see https://github.com/eclipse-langium/langium/discussions/1308. The main idea is to hook into the document builder and to load referenced documents before performing the linking.
At Jayvee, we were evaluating whether we could implement dynamic document loading on imports (https://github.com/jvalue/jayvee/issues/593).
However, we ran into a roadblock as the ScopeProvider has a synchronous interface for the
getScope
method where we ultimately would need to await a promise the loads a document viaservices.shared.workspace.LangiumDocuments.getOrCreateDocument(documentUri)
.If there is a better way to do it in a different place, I'd appreciate your expertise :)
Otherwise, would it be possible to make the interface of the
ScopeProvider
asynchronous by returning promises?This would also affect some methods of the
Linker
and its clients.Let me know if I can contribute anything to that change!