structural search template with method body

Hi,
Can't figure out how to write a template which would search methods by pattern on their body. For example I want to find all static methods which invoke specific method on another class. First I tried

class $Class$ {
  static $ReturnType$ $MethodName$($ParameterType$ $Parameter$) {
      AnotherClass.$MethodName$
  }
}



but it didn't find anything, as far as I understand that's because it looks for exact method body with the only call inside. So I need to define a pattern somewhere like  \.*AnotherClass.$MethodName$\.* bud Idea rejects it saying "This pattern is malformed. It does not match anything in the selected scope". So how to define it? Or, in general, is it a correct way to get the search like I want?

Best regards, Eugene.
0

Search for methods first, then search pattern in "search results" scope

On 8/7/2012 2:54 PM, Yevgen Bushuyev wrote:

Hi,
Can't figure out how to write a template which would search methods by pattern on their body. For example I want to find all static methods which invoke specific method on another class. First I tried

>

class $Class$ {
   static $ReturnType$ $MethodName$($ParameterType$ $Parameter$) {
       AnotherClass.$MethodName$
   }
}

>

but it didn't find anything, as far as I understand that's because it looks for exact method body with the only call inside. So I need to define a pattern somewhere like  \.AnotherClass.$MethodName$\. bud Idea rejects it saying "This pattern is malformed. It does not match anything in the selected scope". So how to define it? Or, in general, is it a correct way to get the search like I want?

>

Best regards, Eugene.

>

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

>

0

Sorry, can't get it working. In the first search template I use

AnotherClass.$MethodCall$($Parameter$)

There are some search results, everything as expceted. Then I want find invocations made from static methods. I create new template, select "Previouis search results" in Scope dropbox, put

$Instance$.$MethodCall$($Parameter$)

into Search template, then Edit Variables->Method Call->Text/Regexp typed static there. Nothing found, though I'm sure there should be results. Even if Text/Regexp is empty it finds nothing. Maybe I should use something else in second Search template?

Best regards, Eugene.

0

AFAIU, you need to use template to find context first (static methods), marking Body as target of search

class $Class$ {
   static $ReturnType$ $MethodName$($ParameterType$ $Parameter$) {
       $Body$
   }
}

0

请先登录再写评论。