Structural Search Problem

I am trying to find all calls to Throwable.printStackTrace() in my
project, so I am using the structural search template:

$Instance$.$MethodCall$($Parameter$)

With $MethodCall$'s text constraints as "printStackTrace".

However it appears to only find the calls that aren't in catch blocks -
it ignores the ones that are.

Am I doing anything stupid? It's my first foray into using S.S. so
forgive any ignorance.

Oh and it's build 3378 by the way.

Cheers,
N.

4 comments
Comment actions Permalink

Seems to be a bug.

Nathan Brown wrote:

I am trying to find all calls to Throwable.printStackTrace() in my
project, so I am using the structural search template:

$Instance$.$MethodCall$($Parameter$)

With $MethodCall$'s text constraints as "printStackTrace".

However it appears to only find the calls that aren't in catch blocks -
it ignores the ones that are.

Am I doing anything stupid? It's my first foray into using S.S. so
forgive any ignorance.

Oh and it's build 3378 by the way.

Cheers,
N.



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

0
Comment actions Permalink

Maxim Mossienko wrote:

Seems to be a bug.

Nathan Brown wrote:

>> I am trying to find all calls to Throwable.printStackTrace() in my
>> project, so I am using the structural search template:
>>
>> $Instance$.$MethodCall$($Parameter$)
>>
>> With $MethodCall$'s text constraints as "printStackTrace".
>>
>> However it appears to only find the calls that aren't in catch blocks
>> - it ignores the ones that are.
>>
>> Am I doing anything stupid? It's my first foray into using S.S. so
>> forgive any ignorance.
>>
>> Oh and it's build 3378 by the way.
>>
>> Cheers,
>> N.


Drat. Any workaround that you can think of?

N.

0
Comment actions Permalink

Use the inspection that does exactly the same thing. You can find it on "Code Maturity Issues", "Call to printStackTrace()".

0
Comment actions Permalink

Marcus Brito wrote:

Use the inspection that does exactly the same thing. You can find it on "Code Maturity Issues", "Call to printStackTrace()".

Good idea, but I actually needed structural replace here to convert
bad printStackTrace() calls to good logger service calls.

I ended up making a template like this, which appeared to work:

try {
$Statements$;
} catch ($Class$ $Instance$) {
$Comments1$;
$Instance$.$MethodCall$($Parameter$);
$Comments2$;
}

Anyone need anymore info on it, drop me a line.

N.

0

Please sign in to leave a comment.