Structural Search and Replace Question

We have a lot of references in our code using static member access, and we'd like to change them all over to using Class references (eg eft.getsomething() -> EftPlugin.getsomething() ).  How can I do this with Structural Search and Replace? (IDEA9.0)

9 comments
Comment actions Permalink

Search for: eft.getsomething()
Replace with: EftPlugin.getsomething()

On 22.01.2010 19:07, Eric Widhalm wrote:

We have a lot of references in our code using static member access, and we'd like to change them all over to using Class references (eg eft.getsomething() ->  EftPlugin.getsomething() ).  How can I do this with Structural Search and Replace? (IDEA9.0)

>

---
Original message URL: http://www.jetbrains.net/devnet/message/5254998#5254998



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

0
Comment actions Permalink

Sorry, Maxim, your response doesn't seem to have made it.  Could you please post again?

0
Comment actions Permalink

Actually, it did too make it, I just didn't notice it up at the top.

> Search for: eft.getsomething()
> Replace with: EftPlugin.getsomething()

The problem is that I want a Structural S&R, where "eft" is any variable, and "EftPlugin" (in my example) is any Class with that static method.

0
Comment actions Permalink

Perhaps I am misunderstanding you, but can't you use the "Access static member via instance reference" inspection for this? It has a quickfix.

Bas

0
Comment actions Permalink

The quickfix functionality is exactly what I want, but it only works on an instance-by-instance basis.  We have potentially hundreds of such individual instances to find and fix, which is why I'd rather use S&R to do it.  It will eliminate the possibility of changing some and not finding others.

0
Comment actions Permalink

On 23.01.2010 0:38, Eric Widhalm wrote:

Actually, it did too make it, I just didn't notice it up at the top.

>
>> Search for: eft.getsomething()
>> Replace with: EftPlugin.getsomething()
>

The problem is that I want a Structural S&R, where "eft" is any variable, and "EftPlugin" (in my example) is any Class with that static method.

>

---
Original message URL: http://www.jetbrains.net/devnet/message/5255024#5255024


when you need any you should introduce variable, like $eft$.getsomething()

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

0
Comment actions Permalink

You know you can run the inspection in batch mode?
Invoke Analyze > Inspect Code..., select the entire project as scope and create a temporary inspection profile containing just this inspection.
Or on an already visible instance of the problem, press Alt+Enter, press Right and select Run Inspection On... from the options.

Bas

0
Comment actions Permalink

I had completely forgotten that I could modify a profile and run the inspections over the whole code as you suggest.  That's a *great* help, and something I will remember.  Thank you, problem resolved.

However, for the sake of learning the S&R feature better (and becoming even more of a power-user), it would be nice to know how I could do this same thing via S&R.  I was hoping to use this as a personal training exercise.

Thank you for the help.

0
Comment actions Permalink

afaik, the problem with S&R is that you cannot use any  conversions to S&R variables
in your case you need to uppercase first letter  eft->Eft

0

Please sign in to leave a comment.