Eclipse Community Forums - RDF feed
https://www.eclipse.org/forums/
Eclipse Community Forumscalling a java extension from inside an Xpand file
https://www.eclipse.org/forums/index.php/mv/msg/17824/57052/#msg_57052
I have the following problem. During the generation of java code out of
an activity diagram I use various extensions written in Java called
through Xtend. The part of the template file calling the extension looks
like the following:
«DEFINE ProcessStoryActivity FOR uml::Activity»
«LET getInitialNode(this) AS initNode»
«ENDLET»
«ENDDEFINE»
the defined extension in the Xtend file looks like:
/**
* Returns the initial node of the activity diagram.
*
* @param act
* the activity diagram
* @return the inital node
*/
public static InitialNode getInitialNode(Activity act) {
....
}
}
So far everything seems to look ok for me, but now when i try to run the
generator file i get the following error:
5393 ERROR AbstractExpressionsUsingWorkflowComponent - Error in
Component generator of type org.openarchitectureware.xpand2.Generator:
EvaluationException : mismatched input '.' expecting '(' on line 1
template::Teststories.xpt[1565,35] on line 59
'getInitialNode((uml::Activity)this)'
this means that somehow i can't call the extension the way i'm doing it,
but unfortunately I can't figure out why. Has anyboday probably got a
hint for me, why this error occurrs?
Thanks a lot!
cheers,
Philipp]]>Philipp Zech2009-02-08T12:44:55-00:00Re: calling a java extension from inside an Xpand file
https://www.eclipse.org/forums/index.php/mv/msg/17824/57111/#msg_57111
> Hi, again me,
>
> I have the following problem. During the generation of java code out of
> an activity diagram I use various extensions written in Java called
> through Xtend. The part of the template file calling the extension looks
> like the following:
>
> «DEFINE ProcessStoryActivity FOR uml::Activity»
> «LET getInitialNode(this) AS initNode»
>
> «ENDLET»
> «ENDDEFINE»
>
> the defined extension in the Xtend file looks like:
>
> org.eclipse.uml2.uml::InitialNode getInitialNode(uml::Activity act) :
> JAVA
> template.Teststories.getInitialNode(org.eclipse.uml2.uml.Act ivity);
>
> and the according implementation pof the java file has the following
> signature:
>
> package template;
>
> import java.util.Iterator;
>
> import org.eclipse.emf.common.util.EList;
> import org.eclipse.uml2.uml.Activity;
> import org.eclipse.uml2.uml.Element;
> import org.eclipse.uml2.uml.InitialNode;
>
> public class Teststories {
>
> /**
> * Returns the initial node of the activity diagram.
> *
> * @param act
> * the activity diagram
> * @return the inital node
> */
> public static InitialNode getInitialNode(Activity act) {
> ....
> }
> }
>
> So far everything seems to look ok for me, but now when i try to run the
> generator file i get the following error:
>
> 5393 ERROR AbstractExpressionsUsingWorkflowComponent - Error in
> Component generator of type org.openarchitectureware.xpand2.Generator:
> EvaluationException : mismatched input '.' expecting '(' on line 1
> template::Teststories.xpt[1565,35] on line 59
> 'getInitialNode((uml::Activity)this)'
>
> this means that somehow i can't call the extension the way i'm doing it,
> but unfortunately I can't figure out why. Has anyboday probably got a
> hint for me, why this error occurrs?
>
> Thanks a lot!
>
> cheers,
>
> Philipp
again resolved,
the reason was that the return type of the declared extension has to be
written like: