Using Java instead of XTend [message #1035320] |
Sat, 06 April 2013 13:55  |
Eclipse User |
|
|
|
XText generates MyDSLValidator.xtend which in turn will generate MyDSLValidator.java
I know I'm in the minority here, but for the time being at least, I'd prefer to not use XTend. Nothing against XTend, it's just that I don't know it and that takes my process from "just figuring it out" to "figuring it out, then figuring it out in xtend".
With my scope provider, I simply named it MyDSLCustomScopeProvider and bound my scope provider in MyDSLRuntimeModule.
But that leaves the .xtend file and it's generated java file in place. My custom code is growing enough that I'd prefer for those extra files not to be there.
I'm using XText 2.4 if that makes a difference.
When I look at earlier projects (xtext 2.3 I believe), the MyDSLValidator.xtend file doesn't exist. I'm unsure if I created the project a little differently, or if it's just one of the differences between 2.3 and 2.4
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Re: Using Java instead of XTend [message #1092122 is a reply to message #1053003] |
Thu, 22 August 2013 07:01   |
Eclipse User |
|
|
|
Steve Kallestad wrote on Wed, 01 May 2013 16:43The easy workaround for me is simply deleting the xtend file, which deletes the auto-generated .java file under src-gen.
I have my own java classes defined with the same names for the validator and scope provider. When I re-run the mwe2 workflow, I simply go and delete those 2 xtend files and everything is fine. I *might* have some hooks declared in the runtime modules, but I don't think I even had to do that.
I appear to be using 2.4.2.v201306120542. Set the var generateXtendStub = false . That change caused the mwe2 workflow to only continue generating .xtend stub for the {ProjectName}Generator.xtend file in the org.xtext.{ProjectFileext}.generator. I can then delete that file as you explained after each re-run of the mwe2 workflow, for a manual work around if I wanted Java source for my code generation.
But I want to use Scala for code generation. Can anyone point me in the direction for learning how to do this?
I realize I might be in the minority, but consider this question applicable to using any JVM language with Xtext for code generation.
Alexei Adamovich wrote on Wed, 01 May 2013 13:31In the situation like this I found the following solution:
since Xtext generates only a stub (written in Xtend), I had got an instance of my Java class there and then had called its method.
So the real work was being done by code written in Java.
Could I call a method in .jar? What do I do to integrate such into the work flow?
[Updated on: Thu, 22 August 2013 10:21] by Moderator
|
|
|
|
|
|
|
Re: Using Java instead of XTend [message #1744668 is a reply to message #1092331] |
Thu, 29 September 2016 07:33  |
Eclipse User |
|
|
|
You can also extend the class generated in xtend-gen folder. Add your functions in this class. In the RuntimeModule class just bind this. And bingo.. You don't need to be worry about anything after that.
|
|
|
Powered by
FUDForum. Page generated in 0.05884 seconds