Structural Search against return type of Annotated method in IntelliJ 13

481 Views Asked by At

As per the subject, I am trying to structurally search against all methods annotated with a specific annotation and with a specific return type.

To be clearer, if I have methods like the followings:

@MyAnnotation
public String myMethod1(){}

and

@MyAnnotation
public Integer myMethod2(){}

I would like to find a way to formulate a structural search in IntelliJ to find, e.g., "all methods annotated with @MyAnnotation and with return type of String" and such search would return only myMethod1().

I am using IntelliJ 13 Ultimate.
Thanks.

2

There are 2 best solutions below

0
On

Using Structural Search, copy the existing template Methods of the class. Modify it as follows:

class $Class$ { 
  @MyAnnotation
  $ReturnType$ $MethodName$($ParameterType$ $Parameter$);
}

And edit the $ReturnType$ variable to specify Text/Regexp:
String (or optionally to be really sure java\.lang\.String)

0
On

I would use Find in Path with Regular expression.
Text to find: would be something like that:

@MyAnnotation\n\spublic.*myMethod1()

regards