|Symptom and Solution for Unresolved Xtext Cross-References [message #997464]
||Mon, 07 January 2013 16:10
| Michael Colburn
Registered: November 2012
The purpose of this post is to pass on a solution to a problem I encountered, in hopes that it will be helpful to someone else in the future. |
1. Your grammar has rules for Objects of type A, that allows a cross-reference to objects of type B.
2. An instance of object type B can have a cross-reference to another instance of object type B.
3. When processing resources from within your implementation of IGenerator, all cross-references resolve correctly.
4. But, if you dynamically load a resource, although the cross-reference from Object type A to Object type B resolves correctly, the cross-references from an instance of Object type b to another instance of type b return null. In other words, references to references return null.
In my situation, the cause of the null reference was as follows. When creating the URI for a dynamic load of a resource, I was using a file scheme. It turns out that file based URIs will not properly resolve cross-references to cross-references. The solution is to use platform resource based URIs.
It took hours of experimentation and searching the Internet before I realized what was happening, due to this post: http://www.eclipse.org/forums/index.php/t/169567/http://.
Although Xtext and EMF "experts" are probably aware of this and never make the mistake I did (of using a file based URI instead of platform resource URI), I feel it is important to provide information helpful to those of us who do not have as much experience.
Powered by FUDForum
. Page generated in 0.12234 seconds