[Xpand/Xtend 1.0 RC1] problem when calling a Java method from Xtend in an Xpand template [message #537201] |
Tue, 01 June 2010 14:51 |
Steven Derrien Messages: 50 Registered: July 2009 |
Member |
|
|
Hi,
I have started playing with XPand/Xtext 1.0RC1, and I must say that I am
quite impressed by the work done since 0.7. Sincere Kudos to all
Xtext/Xpand/Xtend developpers.
I ma trying to use a standalone XPand code generator project that uses a
ecore metamodel defined in an external plugins.
To do this I used the Xpand project wizard provided in the 1.0RC1 release.
I first noticed that the builder would complain (a lot of reddich cross
in my sources) when the target ecore metamodel was not found in the
metamodel directory of the xpand project, even though the workflow would
work properly after regitsering the ecore file io the workflow
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
<registerEcoreFile value="file:/C:/Documents and
Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/FSM.ecore "/>
<registerEcoreFile value="file:/C:/Documents and
Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/datapath.ecore "/>
</bean>
To remove the builder errors I copied my ecore file into the metamodel,
an everything went seamlessly until I decided to call Java code from my
xpand template through an Xtend extension.
Here is a excerpt of my Xtend file
***********
import datapath;
List[AbstractBlock] getSortedList(Datapath dp): JAVA
impulsec.SortedCombBlocks.getSortedList(fr.irisa.cairn.model .datapath.Datapath);
***********
and my Java code
***************
package impulsec;
import java.util.List;
import fr.irisa.cairn.model.datapath.AbstractBlock;
import fr.irisa.cairn.model.datapath.Datapath;
public class SortedCombBlocks {
public static List<AbstractBlock> getSortedList(Datapath dp ) {
TopologicalSort sorter = new TopologicalSort();
sorter.schedule(dp);
return sorter.getSortedList();
}
}
***************
When I run the template through MWE, I get the following error :
EvaluationException : datapath::Datapath is not responsible for java
type fr.irisa.cairn.model.datapath.Datapath
After calling google to my rescue, I found the following post which
describes the very same problem.
http://www.eclipse.org/forums/index.php?t=msg&goto=49888 8&
However the suggested workaround doesn't work in my case, the tag
<metaModel /> seems not to be accepted by my workflow mwe (or maybe I
don't know where to use it).
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
<registerEcoreFile value="file:/C:/Documents and
Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/FSM.ecore "/>
<registerEcoreFile value="file:/C:/Documents and
Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/datapath.ecore "/>
</bean>
<!-- changed from oroginal workflow -->
<metaModel id="mm_emf"
class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
<metaModelPackage value="fr.irisa.cairn.model.datapath.DatapathPackage"/>
<metaModelPackage value="fr.irisa.cairn.model.datapath.port.PortPackage"/>
</metaModel>
<!-- load model and store it in slot 'model' -->
<component class="org.eclipse.emf.mwe.utils.Reader">
<uri value="platform:/resource/${model}" />
<modelSlot value="model" />
</component>
59 ERROR WorkflowRunner - [ERROR]: Incompatible Classes:
'org.eclipse.xtend.typesystem.emf.EmfMetaModel' is not a subclass of the
expected class 'org.eclipse.emf.mwe.core.WorkflowComponent'.(Element:
bean metaModel class='org.eclipse.xtend.typesystem.emf.EmfMetaModel'
id='mm_emf' in C:/Documents and
Settings/sderrien/workspace/fr.irisa.cairn.datapath.xpand.co degen/src/workflow/generator.mwe:15;
Reported by: -UNKNOWN-)
3
I am lost, do you have any hint on how to solve this issue.
Thanks you very much in advance,
Steven
|
|
|
Re: [Xpand/Xtend 1.0 RC1] problem when calling a Java method from Xtend in an Xpand template [message #537253 is a reply to message #537201] |
Tue, 01 June 2010 16:44 |
Steven Derrien Messages: 50 Registered: July 2009 |
Member |
|
|
Hi,
I found a solution by myself. As usual, writing the question to the
forum gave me some ideas to solve the problem.
Basically, one should not mixup dynamical models instanciated directly
from the Ecore spec from EMF generated models.
I made the following modifications to my workflow and everything works
seamlessly :
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
<registerEcoreFile
value=" file:/C:workspace/fr.irisa.cairn.model.datapath/model/FSM.ec ore "/>
<registerEcoreFile
value="file:/C:/fr.irisa.cairn.model.datapath/model/datapath.ecore "/>
</bean>
into
<bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" PlatformUri="..">
<registerGeneratedEPackage
value="fr.irisa.cairn.model.datapath.DatapathPackage"/>
</bean>
Steven
Steven Derrien a écrit :
> Hi,
>
> I have started playing with XPand/Xtext 1.0RC1, and I must say that I am
> quite impressed by the work done since 0.7. Sincere Kudos to all
> Xtext/Xpand/Xtend developpers.
>
> I ma trying to use a standalone XPand code generator project that uses a
> ecore metamodel defined in an external plugins.
>
> To do this I used the Xpand project wizard provided in the 1.0RC1 release.
>
> I first noticed that the builder would complain (a lot of reddich cross
> in my sources) when the target ecore metamodel was not found in the
> metamodel directory of the xpand project, even though the workflow would
> work properly after regitsering the ecore file io the workflow
>
> <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
> <registerEcoreFile value="file:/C:/Documents and
> Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/FSM.ecore "/>
>
> <registerEcoreFile value="file:/C:/Documents and
> Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/datapath.ecore "/>
>
> </bean>
>
>
> To remove the builder errors I copied my ecore file into the metamodel,
> an everything went seamlessly until I decided to call Java code from my
> xpand template through an Xtend extension.
>
> Here is a excerpt of my Xtend file
>
> ***********
> import datapath;
>
> List[AbstractBlock] getSortedList(Datapath dp): JAVA
> impulsec.SortedCombBlocks.getSortedList(fr.irisa.cairn.model .datapath.Datapath);
>
> ***********
>
> and my Java code
>
> ***************
> package impulsec;
>
> import java.util.List;
>
> import fr.irisa.cairn.model.datapath.AbstractBlock;
> import fr.irisa.cairn.model.datapath.Datapath;
>
> public class SortedCombBlocks {
>
> public static List<AbstractBlock> getSortedList(Datapath dp ) {
> TopologicalSort sorter = new TopologicalSort();
> sorter.schedule(dp);
> return sorter.getSortedList();
> }
>
> }
> ***************
>
>
> When I run the template through MWE, I get the following error :
>
> EvaluationException : datapath::Datapath is not responsible for java
> type fr.irisa.cairn.model.datapath.Datapath
>
> After calling google to my rescue, I found the following post which
> describes the very same problem.
>
> http://www.eclipse.org/forums/index.php?t=msg&goto=49888 8&
>
> However the suggested workaround doesn't work in my case, the tag
> <metaModel /> seems not to be accepted by my workflow mwe (or maybe I
> don't know where to use it).
>
> <bean class="org.eclipse.emf.mwe.utils.StandaloneSetup" platformUri="..">
> <registerEcoreFile value="file:/C:/Documents and
> Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/FSM.ecore "/>
>
> <registerEcoreFile value="file:/C:/Documents and
> Settings/sderrien/workspace/fr.irisa.cairn.model.datapath/mo del/datapath.ecore "/>
>
> </bean>
>
>
> <!-- changed from oroginal workflow -->
> <metaModel id="mm_emf"
> class="org.eclipse.xtend.typesystem.emf.EmfMetaModel">
> <metaModelPackage value="fr.irisa.cairn.model.datapath.DatapathPackage"/>
> <metaModelPackage value="fr.irisa.cairn.model.datapath.port.PortPackage"/>
> </metaModel>
>
> <!-- load model and store it in slot 'model' -->
> <component class="org.eclipse.emf.mwe.utils.Reader">
> <uri value="platform:/resource/${model}" />
> <modelSlot value="model" />
> </component>
>
>
> 59 ERROR WorkflowRunner - [ERROR]: Incompatible Classes:
> 'org.eclipse.xtend.typesystem.emf.EmfMetaModel' is not a subclass of the
> expected class 'org.eclipse.emf.mwe.core.WorkflowComponent'.(Element:
> bean metaModel class='org.eclipse.xtend.typesystem.emf.EmfMetaModel'
> id='mm_emf' in C:/Documents and
> Settings/sderrien/workspace/fr.irisa.cairn.datapath.xpand.co degen/src/workflow/generator.mwe:15;
> Reported by: -UNKNOWN-)
> 3
>
> I am lost, do you have any hint on how to solve this issue.
>
> Thanks you very much in advance,
>
> Steven
>
|
|
|
Powered by
FUDForum. Page generated in 0.02377 seconds