Skip to main content



      Home
Home » Modeling » TMF (Xtext) » Xtend help
Xtend help [message #704833] Fri, 29 July 2011 01:55 Go to next message
Eclipse UserFriend
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 02:11 Go to previous message
Eclipse UserFriend
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: Mon Jul 07 10:39:20 EDT 2025

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

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

Back to the top