Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[jdt-dev] About the rewrite problem

Hi, all,
 
I am new to JDT develop. I want to write a program that will behave in the following way :
 
Input : line number, the start position, end position of the statement.
 
Action: add the statement "System.out.println("Hello");" right before the statement above.
 
The procedure should be like this:
1) parse the source code and find the statement that whose line number, state position and end position is as request.
 
2) perform a rewrite action, add "System.out.println("Hello");"  right before that statement.
 
3) store the change to the file.
 
For example,
given line number=6, start position=2, end position=6;
then after parse, we know the statement a=10;
and after that we should perform the rewrite.
 
Could you tell me how should I do?
Is there any example for me to learn from?
 
Best wishes,
 
Zhang Yu
 


--
                                          Zhang Yu

Back to the top