|How to add a class to the list of imports in the generated Java ? [message #998416]
||Wed, 09 January 2013 23:47
| Ian McDevitt
Registered: December 2012
Sometimes when generating Java output you need insert a few lines of code to use a Java class like an ArrayList if your grammar has a 'many' feature, or a Date or Calendar if you have a 'now' or 'today' literal. However this produces invalid Java since you haven't declared it in the import section first (or later). |
Previously with doGenerate I was able to access an ImportManager and add to it but with xbase and the JvmModelInferrer I don't see how to do this, and it doesn't happen automatically.
Of course, if you use the supplied toField then types do get added but when you are implementing the body code as a string or sequence of Java then you need to use the full FQN such as java.util.ArrayList every time.
I have added my own scope provider and also tried accessing some xbase compiler methods but I can't see how toField is able to add to the import list and I can't.
Anyone know about this?
[Updated on: Wed, 09 January 2013 23:48]
Report message to a moderator
Powered by FUDForum
. Page generated in 0.01522 seconds