You are here

Efficient use of Eclipse Java Search

The documentation for Eclipse Java Search is quite brief; bellow is a guide for efficient use.

There is no search filter for private, package, private or public access and also no filter for static and instance methods. Fortunately the result view shows icons and can be partially filtered.

Searching for methods (Case sensitive: yes, Search for: Method, Limit to: Declarations):

Search string Result
myMethod all unqualified myMethod methods with any number of parameters
myMethod() all unqualified myMethod methods without parameters
myMethod(Object) all unqualified myMethod methods with single parameter of unqualified type Object, it means that myMethod(Integer) will not match
myMethod(Integer) all unqualified myMethod methods with single parameter of unqualified type Integer, it means that for instance myMethod(MyClass.Integer) will match too
myMethod(java.lang.Integer) all unqualified myMethod methods with single parameter of qualified type java.lang.Integer, it means that for instance myMethod(MyClass.Integer) will not match
MyClass.myMethod all partially qualified MyClass.myMethod methods with any number of parameters
mypkg.MyClass.myMethod all fully qualified mypkg.MyClass.myMethod methods with any number of parameters
myMetho*(double, *) all unqualified myMetho* methods with 2 parameters, first parameter of type double, second parameter of any type
* List Select Method and Declaration - search for method declaration returning List (but not ArrayList)
* *List Select Method and Declaration - search for method declaration returning List, ArrayList or anything ending in List

When you search for method references, the above table applies too but Eclipse will take into account type hierarchy, so myMethod(new Integer()) will be matched by search for myMethod(Object).

Note that the search is not case sensitive by default.

Comments

How would you match a method that has two (or more) arguments. For example:

Foo.bar("someString", 5); // where 5 is an int/numeric literal

or

List ls = new List()
Foo.bar(ls);

bar(String, int) should work fine

You can place a cursor at the method a open the Java search dialog, it will insert the search string for you.