Trouble emitting template code after splitting Generator Xtend into two pieces [message #1219896] |
Fri, 06 December 2013 14:44 |
Gary Worsham Messages: 176 Registered: September 2013 |
Senior Member |
|
|
My code generator emits 3 different files. So of course I need 3 code generation methods. The generator Xtend was getting a little large so as usual I wanted to break it into smaller pieces. I succeeded in taking out one of the classes to a separate file, and when I use the debugger, it is actually executing those lines, but nothing is coming out except the comment which I emit in the primary generator class.
Here's the main generator class section where the three different generators get called. toTestCode() creates a new class of the separated code and calls the specific methods.
override void doGenerate(Resource resource, IFileSystemAccess fsa) {
var pkage = "\\com\\holycityaudio\\SpinCAD\\CADBlocks\\"
fsa.generateFile(pkage + resource.className+"CADBlock.java", toCADBlockCode(resource.contents.head as Program))
pkage = "\\com\\holycityaudio\\SpinCAD\\ControlPanel\\"
fsa.generateFile(pkage + resource.className+"ControlPanel.java", toControlPanelCode(resource.contents.head as Program))
pkage = "\\com\\holycityaudio\\SpinCAD\\test\\"
fsa.generateFile(pkage + resource.className+"Test.java", toTestCode(resource.contents.head as Program))
}
def className(Resource res) {
var name = res.URI.lastSegment
// println(name)
return name.substring(0, name.indexOf('.'))
}
def toTestCode(Program pr) {
val blockName = pr.eResource.className
var boop = new SpinCADTestGenerator
boop.genTestHeader(blockName)
boop.testNoConnections(blockName)
boop.testAllConnections(blockName, pr)
boop.genTestCloser()
'''
// do something
'''
}
and here's an example of two of the called methods:
class SpinCADTestGenerator {
def genTestHeader(String blockName) {
'''
package com.holycityaudio.SpinCAD.test;
import javax.swing.SwingUtilities;
import com.holycityaudio.SpinCAD.SpinCADFrame;
import com.holycityaudio.SpinCAD.SpinCADPanel;
import com.holycityaudio.SpinCAD.SpinCADPin;
import com.holycityaudio.SpinCAD.CADBlocks.*;
import com.holycityaudio.SpinCAD.ControlBlocks.*;
public class «blockName+"Test"» {
public «blockName+"Test"»(SpinCADFrame f) {
System.out.println("Start of «blockName»CADBlock unit test..." + "\n");
SpinCADPanel p = new SpinCADPanel(f);
InputCADBlock i = new InputCADBlock(225, 10);
OutputCADBlock o = new OutputCADBlock(225, 290);
'''
}
def genTestCloser() {
'''
// end of test code
}
'''
}
The only thing that is getting generated is the line:
No errors or warnings, and like I said, the debugger does trace through the SpinCADTestGenerator methods. Just nothing is coming out. The generator code that is still in the first file works fine.
?????
Thanks!!!!
GW
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03710 seconds