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)
请先登录再写评论。
Search for: eft.getsomething()
Replace with: EftPlugin.getsomething()
On 22.01.2010 19:07, Eric Widhalm wrote:
>
--
Best regards,
Maxim Mossienko
IntelliJ Labs / JetBrains Inc.
http://www.intellij.com
"Develop with pleasure!"
Sorry, Maxim, your response doesn't seem to have made it. Could you please post again?
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.
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
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.
On 23.01.2010 0:38, Eric Widhalm wrote:
>
>> Search for: eft.getsomething()
>> Replace with: EftPlugin.getsomething()
>
>
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!"
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
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.
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