Structural Search

I love the idea of structural search, but more often than not I can not figure out how to use it. An example of what I am trying to do is search for all try/catch blocks where there is no throw in the catch block.

My Search template is:
try {
$TryStatement$;
} catch($ExceptionType$ $ExceptionDcl$) {
$CatchStatement$;
$throwStuff$;
}

Now, for throw stuff I have tried several options, all of which have failed:
1) set a regular expression of throw.*; and select the Invert condition flag. This resulted in finding all try/catch blocks
2) Set a regular expression of throw.*; , setting the invert condition flag and setting the minimum and maximum count to 0.
3) Set a regular expression of throw.*; , NOT setting the invert condition flag and setting the minimum and maximum count to 0.

Why do these all do the same thing? How can I actually do the serach I am trying to do?

Thanks!

5 comments


It is safe to assume this is not possible with structural search?

Thanks

"simonoff" <no_mail@jetbrains.com> wrote in message
news:12407301.1133152408023.JavaMail.javamailuser@localhost...
>I love the idea of structural search, but more often than not I can not
>figure out how to use it. An example of what I am trying to do is search
>for all try/catch blocks where there is no throw in the catch block.
>

My Search template is:
try {
$TryStatement$;
} catch($ExceptionType$ $ExceptionDcl$) {
$CatchStatement$;
$throwStuff$;
}

>

Now, for throw stuff I have tried several options, all of which have
failed:
1) set a regular expression of throw.*; and select the Invert condition
flag. This resulted in finding all try/catch blocks
2) Set a regular expression of throw.*; , setting the invert condition
flag and setting the minimum and maximum count to 0.
3) Set a regular expression of throw.*; , NOT setting the invert condition
flag and setting the minimum and maximum count to 0.

>

Why do these all do the same thing? How can I actually do the serach I am
trying to do?

>

Thanks!



0

Hi,

I believe that this is intolerable that template 1 is not working
properly (min/max count 0 has not yet supported for statements). JIRA
item, please?

Noone wrote:

It is safe to assume this is not possible with structural search?

Thanks

"simonoff" <no_mail@jetbrains.com> wrote in message
news:12407301.1133152408023.JavaMail.javamailuser@localhost...

>>I love the idea of structural search, but more often than not I can not
>>figure out how to use it. An example of what I am trying to do is search
>>for all try/catch blocks where there is no throw in the catch block.
>>
>>My Search template is:
>>try {
>> $TryStatement$;
>>} catch($ExceptionType$ $ExceptionDcl$) {
>> $CatchStatement$;
>> $throwStuff$;
>>}
>>
>>Now, for throw stuff I have tried several options, all of which have
>>failed:
>>1) set a regular expression of throw.*; and select the Invert condition
>>flag. This resulted in finding all try/catch blocks
>>2) Set a regular expression of throw.*; , setting the invert condition
>>flag and setting the minimum and maximum count to 0.
>>3) Set a regular expression of throw.*; , NOT setting the invert condition
>>flag and setting the minimum and maximum count to 0.
>>
>>Why do these all do the same thing? How can I actually do the serach I am
>>trying to do?
>>
>>Thanks!




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

0

Small clarification,
'all try/catch blocks where there is no throw in the catch' would be
following pattern

try {
$TryStatement$;
} catch($ExceptionType$ $ExceptionDcl$) {
$CatchStatement$;
$throwStuff$;
$CatchStatement2$;
}

additional CatchStatement2 0..max_value

your pattern is
'all try/catch blocks where there is no throw in the catch as last
statement'

Maxim Mossienko wrote:

Hi,

I believe that this is intolerable that template 1 is not working
properly (min/max count 0 has not yet supported for statements). JIRA
item, please?

Noone wrote:

>> It is safe to assume this is not possible with structural search?
>>
>> Thanks
>>
>> "simonoff" <no_mail@jetbrains.com> wrote in message
>> news:12407301.1133152408023.JavaMail.javamailuser@localhost...
>>
>>> I love the idea of structural search, but more often than not I can
>>> not figure out how to use it. An example of what I am trying to do is
>>> search for all try/catch blocks where there is no throw in the catch
>>> block.
>>>
>>> My Search template is:
>>> try {
>>> $TryStatement$;
>>> } catch($ExceptionType$ $ExceptionDcl$) {
>>> $CatchStatement$;
>>> $throwStuff$;
>>> }
>>>
>>> Now, for throw stuff I have tried several options, all of which have
>>> failed:
>>> 1) set a regular expression of throw.*; and select the Invert
>>> condition flag. This resulted in finding all try/catch blocks
>>> 2) Set a regular expression of throw.*; , setting the invert
>>> condition flag and setting the minimum and maximum count to 0.
>>> 3) Set a regular expression of throw.*; , NOT setting the invert
>>> condition flag and setting the minimum and maximum count to 0.
>>>
>>> Why do these all do the same thing? How can I actually do the serach
>>> I am trying to do?
>>>
>>> Thanks!
>>
>>
>>
>>




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

0

It still does not work. Here is the search:

try {
$statements$
} catch($ExceptionType$ $ExceptionDcl$) {
$CatchStatement$;
$throwStuff$;
$CatchStatement2$;
}

For the variables I have the following:
statements - Min=1, Max=unlimited
ExceptionType - Min = Max = 1
ExceptionDcl - Min = Max = 1
CatchStatement - Min = 0, Max = Unlimited
throw stuff - text/reg ex=throw .*; min=0, max=0
CatchStatement2= Min=0, Max=Unlimited

What am I doing wrong???

Thanks

0

$statements$ -> $statements$;

simonoff wrote:

It still does not work. Here is the search:

try {
$statements$
} catch($ExceptionType$ $ExceptionDcl$) {
$CatchStatement$;
$throwStuff$;
$CatchStatement2$;
}

For the variables I have the following:
statements - Min=1, Max=unlimited
ExceptionType - Min = Max = 1
ExceptionDcl - Min = Max = 1
CatchStatement - Min = 0, Max = Unlimited
throw stuff - text/reg ex=throw .*; min=0, max=0
CatchStatement2= Min=0, Max=Unlimited

What am I doing wrong???

Thanks



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

0

Please sign in to leave a comment.