Skip to main content

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

Hi, Zhang.
 
The jdt-dev email list is for people working on the JDT.  If you have questions about how to use the JDT, it is best to post to the eclipse.tools.jdt newsgroup.  You can learn about using the newsgroups at http://www.eclipse.org/newsgroups/ .
 
To learn more about AST rewrites, you may want to read the article at http://www.eclipse.org/articles/article.php?file=Article-JavaCodeManipulation_AST/index.html .
 
Thanks!


From: jdt-dev-bounces@xxxxxxxxxxx [mailto:jdt-dev-bounces@xxxxxxxxxxx] On Behalf Of Yu Zhang
Sent: Friday, June 20, 2008 8:52 AM
To: jdt-dev@xxxxxxxxxxx
Subject: [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