Replies: 8 comments 5 replies
-
There are ways to accomplish what you're trying by creating synthetic nodes, but it requires some effort. Especially if you really want to deal with all the LSP stuff correctly. It would require overriding every service. I would instead recommend to model the JSON spec in Langium (it should be fairly trivial) and register that as a second language in your language server. Not only removes that the need for manual transformation of JSON to langium, but also makes LSP integration a breeze. Note that you shouldn't register the additional language in vscode, since it already has builtin JSON language support. |
Beta Was this translation helpful? Give feedback.
-
I understand. Thank you for the quick resonse. So probably this is too complicated. However, I wonder if not more people have the need to combine their model with external sources (JSON is just a simple example of such a model). I if model the link to my external model as payload (not as langium reference):
instead of
I could perfectly validate my model concerning correctness. --> How difficult would it be to implement completion and goto-reference (less services to reimplement? is it possible to name these services?)? --> is this a better solution compared to the previously formulated? |
Beta Was this translation helpful? Give feedback.
-
This may be related in #712 in some aspects (code completion) |
Beta Was this translation helpful? Give feedback.
-
I created a demo to make it easier to demonstrate what I mean. @cdietrich I would be very happy if you could have a look. Maybe you have some better solution to the problem? @msujew @spoenemann I think the capability to reference arbitrary external models (langium models or non-langium models) would make langium very flexible. What do you think? Comments are very welcome. |
Beta Was this translation helpful? Give feedback.
-
I would try again with your initial approach of proper cross-references before you start implementing all LSP services again. What you need to do is to ensure that the data structure you create in
|
Beta Was this translation helpful? Give feedback.
-
i encounter similar issue too(#1518 ),write a class extends DefaultCompletionProvider truly have a hint for outer call, |
Beta Was this translation helpful? Give feedback.
-
i guess it mainly because outer model don't have document to related to,actually ,i am considering |
Beta Was this translation helpful? Give feedback.
-
I am playing with langium 1.1.0 and I wish to create a model which is interacting with some other model, assuming I have a typescript representation of the other model.
As an example I use JSON as the "foreign" meta-model and JSON-files.
My langium garmmar is then sketched as follows:
I use the artifical AST Nodel "JsonElement" to represent the link to JSON files.
I add a scope provider to implement the lookup and linking:
With this I manage to get a correct completion-and-linking behavior:
my model:
my external hello.json:
However,
Message: Request textDocument/documentHighlight failed with message: AST node has no document.
Code: -32603 '
Beta Was this translation helpful? Give feedback.
All reactions