|Using Xtend for template code generation without a grammar [message #1220225]
||Tue, 10 December 2013 13:28
| Gary Worsham
Registered: September 2013
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
Powered by FUDForum
. Page generated in 0.02950 seconds