A zany refactoring question [message #153860] |
Thu, 06 November 2003 22:21 |
Eclipse User |
|
|
|
Originally posted by: johnhkc.earthlink.net
I'd like to know if the following is possible using Eclipse.
This is for use in a code generator.
Imagine I have a piece of Java code that stretches over many lines and
builds a String like this:
String mystr = "the " +
"cow " +
"said " +
"moo " +
"moo " +
"moo " +
"! ";
I want to write a refactoring routine where the user hilights a line that
will have a condition added. For example, I could highlight the last
"moo" and the refactoring routine would add an IF so that the code changes
to this:
String mystr = "the " +
"cow " +
"said " +
"moo " +
"moo ";
if ( someFlag == true )
{
mystr += "moo ";
}
mystr += "!";
Is there a way to programmatically parse through the String declaration,
see the last "moo", end the statement before it, surround the last "moo"
with a condition and append the trailing "!" as in the code above?
|
|
|
Re: A zany refactoring question [message #153926 is a reply to message #153860] |
Fri, 07 November 2003 04:53 |
Eclipse User |
|
|
|
Originally posted by: akiezun.cuthis.mit.edu.andthis
the jdt group would be better for your question
look into ASTRewrite and its friends
it's internal stuff for now but there's work on making it API for 3.0
a.
|
|
|
|
Powered by
FUDForum. Page generated in 0.03777 seconds