i guess you have a basic missunderstandling of what the code gen is.
the code gen is a program that operates on the AST and not the text.
thus you might have an Item in your hand. an item has subclasses Operation and Event.
you can do instanceof checks and you can make use of dispatch functions in Xtend.
this might give you some hints on where to start.
since you do not give any context i cannot say what is better in your case