Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » TMF (Xtext) » Using Xtend for template code generation without a grammar(Noob)
Using Xtend for template code generation without a grammar [message #1220225] Tue, 10 December 2013 13:28 Go to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
I started using Xtext and Xtend to automatically generate classes and unit test cases for functional blocks which comprise the library for a CAD system I wrote.

Initially (prior to discovering DSLs) I wrote a bunch of block classes directly in Java, until I got tired of the repetition and figured out the easier way to do it (Xtext/Xtend). Some of those original classes written in Java have more elaborate features than is possible to represent with my current DSL model. I am OK leaving those written in Java for now but I would still like to use my unit test code generator to create unit test cases for them.

And rather than reading a DSL source file, I'd prefer to have the test code generator simply look in a specific place for a specific file name pattern (*CADBlock.java) and then use that name to generate the test case classes for each matching file.

Right now the test case code is isolated in its own Xtend class so all I have to do is to instantiate the class and send it a block class name (i.e. the "*" in *.CADBlock.java). I know that the DSL code generator gets triggered when I save a DSL source file. However, this is part of my DSL workspace, not my application workspace (which uses the DSL plug-ins).

I guess I could import the relevant code-generator Java code into my application workspace. Then I could have Java code look for the matching files and then send the substring over to the Java version of the code generator, to create the unit test classes each time the application runs, right before they are used. It seems a little clunky. Any suggestions as to a cleaner approach? I don't want to have to maintain two copies of the test code generator Java source.

[Updated on: Tue, 10 December 2013 14:11]

Report message to a moderator

Re: Using Xtend for template code generation without a grammar [message #1220280 is a reply to message #1220225] Tue, 10 December 2013 19:35 Go to previous messageGo to next message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Hi,

sorry i actually understand nothing. can you please elaborate what you actually want todo
and of course you can use xtend to generate code without grammar.


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de

[Updated on: Tue, 10 December 2013 19:41]

Report message to a moderator

Re: Using Xtend for template code generation without a grammar [message #1220296 is a reply to message #1220280] Tue, 10 December 2013 22:36 Go to previous messageGo to next message
Gary Worsham is currently offline Gary WorshamFriend
Messages: 176
Registered: September 2013
Senior Member
I think what I'm going to do is to just create a Java application that scans the directories for existing Java files and then calls the Xtend to create the unit tests. It won't be triggered automatically. I'll run it when I feel like it and it will generate tests for whatever is there at the time.
Re: Using Xtend for template code generation without a grammar [message #1220320 is a reply to message #1220296] Wed, 11 December 2013 06:30 Go to previous message
Christian Dietrich is currently offline Christian DietrichFriend
Messages: 14665
Registered: July 2009
Senior Member
Simply give it a try?

--
Need training, onsite consulting or any other kind of help for Xtext?
Go visit http://xtext.itemis.com or send a mail to xtext at itemis dot de


Twitter : @chrdietrich
Blog : https://www.dietrich-it.de
Previous Topic:Error while starting xtext-Editor as RCP
Next Topic:Create a custom mapping from mydsl to JVM concepts
Goto Forum:
  


Current Time: Tue Apr 23 08:47:45 GMT 2024

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

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

Back to the top