4.5 struct search for static init
In 4.5, how can I do a structural search for a static init block? E.g., a class contains
static {
version = 42;
}
But, a structural search on that file with a user defined template containing
static {
version = 42;
}
returns "No occurrences found".
Cheers,
11011011
请先登录再写评论。
Hi,
Try use pattern:
class $a$ {
static {
version = 42;
}
}
J. David Beutel wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Thanks for your help! But, that pattern matches every class, even ones without any static init block. Also, it seems to match the class, not the block.
All of my classes contain a static init block that I want to replace (actually, delete). But, some of my classes have additional static init blocks that I do not want to delete. Can 4.5's structural search do this?
Cheers,
11011011
Hi,
It turned out to be the bug in the matching of class initializers, thank
you for the reporting it, it will go to the next update release of 4.5.
J. David Beutel wrote:
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Thanks! I'm looking forward to it.
11011011
Hi,
Replacement of static initializers from some class looks like following:
Search:
class $a$ {
static {
a = 20; // code you want to be in static initializer
}
$AllOtherClassStuff$
}
Replacement:
class $a$ {
$AllOtherClassStuff$
}
Maxim Mossienko wrote:
>> Thanks for your help! But, that pattern matches every class, even
>> ones without any static init block. Also, it seems to match the
>> class, not the block.
>>
>> All of my classes contain a static init block that I want to replace
>> (actually, delete). But, some of my classes have additional static
>> init blocks that I do not want to delete. Can 4.5's structural search
>> do this?
>>
>> Cheers,
>> 11011011
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"