How does Xtext resolve references? [SOLVED] [message #1180983] |
Mon, 11 November 2013 09:38 |
Jens Rabe Messages: 81 Registered: September 2013 |
Member |
|
|
For my language, I defined a reference to an external model in my grammar, it is referenced by its URI with its fragment, like this:
myOtherReference="platform:/resource/SomeProject/somefolder/MyOtherModel.mdl#/"
My scope provider knows the MyOtherModel, assembles a scope using this URI as the qualified name and the concrete instance of the MyOtherModel in its EObjectDescription. However, I get the error "Couldn't resolve reference to MyOtherModel 'platform:/resource/SomeProject/somefolder/MyOtherModel.mdl#/'". The strange thing is, the editor offers me a quick fix to set the myOtherReference to EXACTLY this URI. What else might I be missing? Do I have to add some other bits at a different location I do not know?
[Updated on: Mon, 11 November 2013 13:10] Report message to a moderator
|
|
|
Re: How does Xtext resolve references? [SOLVED] [message #1181231 is a reply to message #1180983] |
Mon, 11 November 2013 13:15 |
Jens Rabe Messages: 81 Registered: September 2013 |
Member |
|
|
I solved it by examining the scoping mechanism single-stepping through it with the debugger. At some point when the model is deserialized from the DSL source code, it comes to the myOtherReference=... line where it converts the string to a QualifiedName. But this QualifiedName uses the dot as a delimiter so the deserializer ends up producing a QN with two segments - platform:/resource/SomeProject/somefolder/MyOtherModel and mdl#/. In my scope provider however, I use the URI as a single segment. At first I did not discover this because toString() produces the same result for the different QNs. I ended up splitting the URI at the dot and constructing QNs with multiple segments in the scope provider. So, the correct object can be resolved.
[Updated on: Mon, 11 November 2013 13:17] Report message to a moderator
|
|
|
Powered by
FUDForum. Page generated in 0.01317 seconds