[Xpand] Error "Couldn't find property 'a' for type 'b::c'" when "a" is EDataType [message #662163] |
Tue, 29 March 2011 15:02 |
Christoph Wienands Messages: 55 Registered: July 2009 |
Member |
|
|
Hello all,
I'm pulling my hair trying to figure out what is going on. We have a number of Xpand templates that operate on a metamodel. This metamodel was imported from an XSD and we can't really change it for compatibility.
In the .xpt files we are seeing a lot of error messages like "Couldn't find property 'a' for type 'b::c'". We found out that this only happens for properties that are of EDataType. Now, all these EDataType have "float" or other simple data types set. The EMF genmodel generator is smart enough to map this to "short" or other simple datatypes without the need for an intermediate class. However, Xpand does not seem smart enough to do that.
Previously with the Galileo version we would see error messages in the editor but the templates still were executed properly. So for that time we simply ignored the errors. However, we recently upgraded to Helios and switched to "org.eclipse.xpand2", and now even the template expansion does not work anymore.
I have done some research and found this bug report: https://bugs.eclipse.org/bugs/show_bug.cgi?id=281269 that seems related even though it is about Xtend.
Unfortunately, I don't understand how the workaround can be implemented, particularly for Xpand templates. All I found when searching for "JavaBeansMetaModel" were statements like "you need to use this" but never how this is done.
Could someone tell me how I can work with attributes of EDataType in Xpand templates, using the "JavaBeansMetaModel" workaround or any other way?
Thanks a lot, Christoph
[Updated on: Tue, 29 March 2011 15:07] Report message to a moderator
|
|
|
Re: [Xpand] Error "Couldn't find property 'a' for type 'b::c'" when "a" is EData [message #662174 is a reply to message #662163] |
Tue, 29 March 2011 15:41 |
|
The EMF typesystem is not aware of handling EDataTypes. It only knows how to handle primitives or references. EDataTypes are just "Object".
When using the JavaBeansMetaModel this maps to Java classes, i.e. a class is a type, JavaBeans properties are properties, all other methods are operations. The namespace is not the NS prefix, it's the java package (foo::bar::something). This needs adjustments in templates, since EMF types and Java types behave slightly different.
To use the JavaBeansMetaModel just register org.eclipse.xtend.type.impl.java.JavaBeansMetaModel instead of the EmfRegistryMetaModel in the workflow, that's all.
In EMF classes produced for the EDataTypes they would map to their instance class, i.e. the datatypes are resolved to real types. So using the JavaBeansMetaModel would work here.
Kind regards,
~Karsten
Need professional support for Xtext, EMF, Eclipse IDE?
Go to: http://devhub.karakun.com
Twitter : @kthoms
Blog : www.karsten-thoms.de
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.02799 seconds