0

I want something similar to this, but within the scope of a method.

Given a project, I want to find all the files with a method which return an specific Object and use another specific method.

Currently I only have this: MyObject(.)*\((.)*\)[\w\W]*?return which selects the method with the return I expect, but how can I specify a behaviour inside of it?

Feel free to use another simpler pattern, I don't know if the one I've created is good enough.

And please, explain the Regex as I am not an expert of it, and for future purposes also.

Community
  • 1
  • 1
Patrick Bard
  • 1,804
  • 18
  • 40
  • 2
    I would suggest using [Structural Search](https://www.jetbrains.com/idea/help/structural-search-and-replace-examples.html) – Meo May 18 '15 at 13:07
  • I'm not sure if regex is the right tool for this job. What's your endgame for this? – JNYRanger May 18 '15 at 13:07
  • Actually I never used Structural Search on IntelliJ, I will give it a try. But so far seems just another reason for me to love the IDE. – Patrick Bard May 18 '15 at 13:37
  • @JNYRanger Yeah I agree with you, but that was the first thing that cross my mind. I have a huge project, and we notice an unnecessary use of an Object. But the object have a quite common use, what I asked would filter almost perfectly the situation where it is really unnecessary. I mean from more de 3k files to something around 50. – Patrick Bard May 18 '15 at 13:43

1 Answers1

2

Not exactly what you want, but you could perform a search with the scope Files in Previous Search Result.

Structural Search seems like a better solution to your problem. Use the existing template methods of the class and edit the variable ReturnType to equal the type you want. Then use the template method calls and edit the variable MethodCall and search in scope Previous Search Results.

Bas Leijdekkers
  • 23,709
  • 4
  • 70
  • 68
  • Thank you for suggesting a better solution (the same go to @Meo). As I said before, just one more reason to love IntelliJ :) – Patrick Bard May 18 '15 at 14:02