mdm
mdm

Reputation: 3988

Structural Search against return type of Annotated method in IntelliJ 13

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.

Upvotes: 1

Views: 564

Answers (2)

Bas Leijdekkers
Bas Leijdekkers

Reputation: 26482

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)

Upvotes: 1

elou
elou

Reputation: 1282

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

@MyAnnotation\n\spublic.*myMethod1()

regards

Upvotes: 0

Related Questions