|
|
|
Re: Help with modifying source and variables views during debugging (redirected) [message #1773080 is a reply to message #1773019] |
Thu, 21 September 2017 09:13 |
Nikita Dümmel Messages: 19 Registered: September 2017 |
Junior Member |
|
|
After debugging the org.eclipse.xtext.builder.smap.DebugSourceInstallingCompilationParticipant I have compared the ._trace files generated by an xbase example and by my codegen.
It seems the problem is that my trace files lack the useForDebugging attribute set to true for the required trace regions. The appended files show examples of xbase generated trace and that for my DSL. The regions marked with D have this attribute set to true.
When writing the generator I have followed this example.
How can I set certain lines to be able to be used by debugger (useForDebugging to true in trace region) during code generation?
For example each generated statement from the code below should have this attribute set to true.
Here is an excerpt from my generator.
override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) {
val program = resource.contents.head as Program
if (program !== null) {
val programName = resource.URI.lastSegment.nameWithoutExtension.toFirstUpper
AthenaUtilGenerator.generateUtilFile(resource, fsa, context)
TurtleUtilGenerator.generateUtilFile(resource, fsa, context)
fsa.generateTracedFile("generated/" + programName + ".java", program, '''
package generated;
import java.util.ArrayList;
import java.util.Arrays;
/*
* Generated Java file, do not modify it!!!
*/
@SuppressWarnings("all")
public class «programName» {
static AthenaUtil util = new AthenaUtil();
«FOR typeDec : program.typeDeclarations»
«IF typeDec instanceof Composition»
«fsa.generateTracedFile("generated/" + typeDec.name + ".java", program, '''
package generated;
/*
* Generated Java file, do not modify it!!!
*/
public class «typeDec.name» {
«FOR attr : (typeDec as Composition).attributes»
«attr.generateAttribute»
«ENDFOR»
}
''')»
«ENDIF»
«IF typeDec instanceof Enumeration»
«fsa.generateTracedFile("generated/" + typeDec.name + ".java", program, '''
package generated;
/*
* Generated Java file, do not modify it!!!
*/
public enum «typeDec.name» {
«FOR value : (typeDec as Enumeration).values»
«value.name.toUpperCase»
«IF !(typeDec as Enumeration).values.get((typeDec as Enumeration).values.size-1).equals(value)», «ENDIF»
«ENDFOR»
}
''')»
«ENDIF»
«ENDFOR»
«FOR op : program.operations»
«op.generateOperation»
«ENDFOR»
«IF program.mainBlock !== null»
«program.mainBlock.generateMainMethod»
«ENDIF»
}
''')
}
}
@Traced def private generateOperation(Operation op) {
'''
«op.generateMethodSignature»{
«FOR s : op.block.statements»
«s.generateStatement»
«ENDFOR»
}
'''
}
def private generateStatement(Statement s) {
val n = s.trace
switch s {
VariableDeclaration: {
s.generateVariableDeclaration(n)
n.append(";")
}
Assignment: {
s.generateAssignment(n)
n.append(";")
}
OperationCall: {
s.generateOperationCall(n)
n.append(";")
}
Conditional: {
s.generateConditional(n)
}
WhileLoop: {
s.generateWhileLoop(n)
}
ForEachLoop: {
s.generateForEachLoop(n)
}
Return: {
n.append("return ")
s.expression.generateExpression(n)
n.append(";")
}
}
return n
}
Regards,
Nikita.
|
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.04492 seconds