Complex path leads to unresolved cross reference despite working scoping #1773
-
Hello all! I'm finding myself facing a problem, but my grammar is getting really complex, so I will try to explain it as clearly as possible. I'm using the DocumentBuilder to generate AstNodes from my files and navigating through them via cross references. My files show no validation error, and my scoping works so I expect that none of my references should be unresolved in the AstNodes I get from the DocumentBuilder. Here is how I build my AstNodes :
This works fine, I build the AstNodes. In my language I call the entry Model. However, while trying to access a specific complex path, i get an unresolved reference. The following path is correct based on my language AST:
This returns undefined which is not what I expect. In this specific case, I navigate through several cross-reference and the last one is a cross reference to an AstNode in another Model than the Model containing the What confuses me the most is that I can access other nodes from different Models by following other paths and cross references. This one is the only one that returns undefined. I have no idea what I do wrong here. Is there a limit of cross references I can access in my Model AstNode? Or do I misunderstand how global scoping works when using the DocumentBuilder? I will appreciate any help or lead to find the answer. Thank you! |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Hey @antoinelilly, So generally, it should not matter how many references you attempt to resolve in a single expression chain. In fact, since you run the full document builder beforehand, each reference is resolved first independently and then cached. When accessing the As for the error: I'm actually not entirely sure what could be the issue here. I would need a reproducible example for that. One thing that can be improved in your code is to execute the document builder only once with all documents (that's why the document builder accepts an array). However, that shouldn't influence the behavior of the linking, it's only a performance optimization. You might want to try that anyway. Given that all the other references resolve correctly, I'm inclined to think that this might be a minor error in your linking/scoping code. I would recommend to isolate the DSL snippet and write a test to try to reproduce and then debug everything. |
Beta Was this translation helpful? Give feedback.
-
Hello @msujew! Surprisingly, I took your advice to improve my code with the DocumentBuilder and it completely fixed the problem. I'm guessing maybe it did influence the behavior of the linking? Thank you for your insight! |
Beta Was this translation helpful? Give feedback.
Hey @antoinelilly,
So generally, it should not matter how many references you attempt to resolve in a single expression chain. In fact, since you run the full document builder beforehand, each reference is resolved first independently and then cached. When accessing the
ref
value, you're actually just accessing that cached value.As for the error: I'm actually not entirely sure what could be the issue here. I would need a reproducible example for that. One thing that can be improved in your code is to execute the document builder only once with all documents (that's why the document builder accepts an array). However, that shouldn't influence the behavior of the linking, it's only a perfo…