Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Xtend help
Xtend help [message #704833] Fri, 29 July 2011 05:55 Go to next message
Arun  is currently offline Arun Friend
Messages: 26
Registered: July 2011
Junior Member
Hi,

In my model i have different types. For each type i will have to get the filepath, scope etc. which are common to all types. I use xtend along with JAVA to get the filepath and other details. Do i have to write methods to get the filepath and others for each Type.? Is it possible to do it in a generic way?, instead of repeating methods for each Type.

Model :
name=ID
(packages+=Package)*;

Package:
"package" name=QualifiedName '{'
(types+=Type)*
'}';

Type:
DataType | Droplet | FormHandler | Properties | JSP | Schedular | GenericService | MessageSource | MessageSink | MessageSourceSink | DynamoMessageConfig ;

========================

Xpand template
==============

«DEFINE droplet FOR Droplet»
«FILE getPropertyFilePath()+ getPropertyFileName() +".properties"»
«ENDFILE»
«ENDDEFINE»

«DEFINE formhandler FOR FormHandler»
«FILE getPropertyFilePath()+ getPropertyFileName() +".properties"»
«ENDFILE»
«ENDDEFINE»

«DEFINE schedular FOR Schedular»
«FILE getPropertyFilePath()+ getPropertyFileName() +".properties"»
«ENDFILE»
«ENDDEFINE»

=========================

Xtend
=======

boolean getPropertyFileName(Droplet d) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.Droplet);

boolean getPropertyFileName(FormHandler f) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.FormHandler);

boolean getPropertyFileName(Schedular s) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.Schedular);

//Instead of writing the above ones, can't we do it with Type like below and get the file path for respective Type.

boolean getPropertyFileName(Type t) :
JAVA com.JavaUtil.getPropertyFileName(com.atgdsl.atgDsl.Type);

I don't want to do isntanceof check and type casting.

Thanks,
Arun
Re: Xtend help [message #704847 is a reply to message #704833] Fri, 29 July 2011 06:11 Go to previous message
Alexander Nittka is currently offline Alexander NittkaFriend
Messages: 1193
Registered: July 2009
Senior Member
Hi,

hi, if you need the type information in java in order to calculate the stuff, you either have to do type checking/casting, or you have to write one java extension for every type.
If you don't need the type information, you could simply write one extension for Type, as that seems to be the super type of all of them.

Alex
Previous Topic:Regex and Xtext
Next Topic:Splitting to multiple resources
Goto Forum:
  


Current Time: Tue Apr 16 14:01:56 GMT 2024

Powered by FUDForum. Page generated in 4.01334 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top