Structural search question

Hi

How can I find both

static JButton x;
static JButton x = new JButton();

using a structural search.

I can find
static JButton x;
using
static $classname$ $varname$
but not both of the statements mentioned above.

Thanks for your help.

--Etienne

7 comments
Comment actions Permalink

static JButton x = $Initial$;
For $Initial$ occurence count min 0, max 1

etienne wrote:

Hi

How can I find both

static JButton x;
static JButton x = new JButton();

using a structural search.

I can find
static JButton x;
using
static $classname$ $varname$
but not both of the statements mentioned above.

Thanks for your help.

--Etienne



--
Maxim Mossienko
JetBrains, Inc
http://www.jetbrains.com
"Develop with pleasure!"

0
Comment actions Permalink

Works like a charm.
Thanks Maxim!

0
Comment actions Permalink

And how about one more condition?
I want to find all static String fields which have non-literal initializer.
So I use the following template:
static String $FieldName$ = $Init$;

where $Init$ is not like: ".*", min occurs: 0 max occurs: 1
But it seems to me IDEA (#5261) finds all static String fields whatever initializer they have (e.g. private static final String ON_DELETE = "onDelete";).
What's wrong?

0
Comment actions Permalink

Hi,

SSR seems expand literal values when do comparison, try search for:
static String $FieldName$ = "$Init$";, Init should have inverted
condition of text .*

Dmitry Cherniachenko wrote:

And how about one more condition?
I want to find all static String fields which have non-literal initializer.
So I use the following template:
static String $FieldName$ = $Init$;

where $Init$ is not like: ".*", min occurs: 0 max occurs: 1
But it seems to me IDEA (#5261) finds all static String fields whatever initializer they have (e.g. private static final String ON_DELETE = "onDelete";).
What's wrong?



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

0
Comment actions Permalink

Damn. Have just installed #5281 and it does not allow deleting characters in SS template editor. :( Cursor navigation with keyboard does not work either. :(
http://www.jetbrains.net/jira/browse/IDEA-7744

However, searching for
private String $Symbol$ = "$init$";
where $Symbol$ - occurs: 1, $init@ - not like .*, min:0, max:unlimited
still gives no results. :(
So, I suppose template is not quite correct. (IMO, .* matches anything, so inverting this condition just gives no matches)

Should I submit new request to JIRA?

0
Comment actions Permalink

Surely.

Dmitry Cherniachenko wrote:

Damn. Have just installed #5281 and it does not allow deleting characters in SS template editor. :( Cursor navigation with keyboard does not work either. :(
http://www.jetbrains.net/jira/browse/IDEA-7744

However, searching for
private String $Symbol$ = "$init$";
where $Symbol$ - occurs: 1, $init@ - not like .*, min:0, max:unlimited
still gives no results. :(
So, I suppose template is not quite correct. (IMO, .* matches anything, so inverting this condition just gives no matches)

Should I submit new request to JIRA?



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

0

Please sign in to leave a comment.