2

I've searched for the methods of generating code in java source code. As you know, there are several methods for accomplishing this tasks using JDT AST or CodeModel. As I've understood, these methods facilitate generating java source code from scratch. But the functionality I'm seeking for is to inject some java code snippet to an existing java class (.java file), according to current state of the program (defined variables, etc). To make it more clear, consider the following class. My question is how to generate and add some code (e.g. a switch structure) at point "A"? Could you provide me tutorials or the starter code?

package test;

public class Test {

    public static void main(String[] args) {
        //Some code...

        //"A" point

        //Some other code...    
    }
}

Thanks in advance. :-)

0 Answers0