Structural replace: surround logger.debug(...) block with if (logger.isDebugEnabled())

Hi,

I was wondering if I could use structural replace to do the following:

Replace blocks like:

logger.debug("This is value" + value);
logger.debug("blah blah");
logger.debug("Thread: " + Thread.currentThread().toString());

with :

if (logger.isDebugEnabled()) {
logger.debug("This is value" + value);
logger.debug("blah blah");
logger.debug("Thread: " + Thread.currentThread().toString());
}

I'd like to skip over blocks that are already surrounded by the if
condition..

Is this possible?

Omair

2 comments
Comment actions Permalink

Hi,

Right now it is not possible but this feature is planned

Omair-Inam Abdul-Matin wrote:

Hi,

I was wondering if I could use structural replace to do the following:

Replace blocks like:

logger.debug("This is value" + value);
logger.debug("blah blah");
logger.debug("Thread: " + Thread.currentThread().toString());

with :

if (logger.isDebugEnabled()) {
logger.debug("This is value" + value);
logger.debug("blah blah");
logger.debug("Thread: " + Thread.currentThread().toString());
}

I'd like to skip over blocks that are already surrounded by the if
condition..

Is this possible?

Omair



--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"

0
Comment actions Permalink

There is an inspection/quick fix for single log statements of the described scenario if the SimpleIntentions plugin is installed.

See also
http://www.intellij.net/forums/thread.jspa?messageID=5116689

etienne

0

Please sign in to leave a comment.