Get the methods that return an object of specific class type, using Eclipse Helios

641 Views Asked by At

While working with Calendar API, I found that getTime() is its only method that returns a Date object.

But to know this, I manually checked all the methods using Content Assist (Ctrl + Space) in Eclipse Helios.

So, I wonder is there some way in Eclipse to get the list of methods that return an object of some specific class?

If that is possible, it would make the use of different classes very easy. Because when I want to convert one entity into other, both will be of some ClassType. Then if I can get the list of methods that convert from one to other, I will only need to check the functionality of those methods directly and use the most eligible one! This would be great

1

There are 1 best solutions below

0
On

If you write

Calendar c = Calendar.getInstance();
Date d = c.[ctrl+space]

You will get the content assist window with all methods that return a Date at the top of the list. In general Eclipse is able to give you better hints if you use content assist in a particular context (here, an assignment).

Another example, if you have a method

private void methodExpectsDate(Date d);

And use content-assist this way

methodExpectsDate(c.[ctrl-space]);

The Calendar method that returns a Date will also be placed on top of the suggestion list.

EDIT: note that this won't work unless you have selected "Sort proposals [by relevance]" in the java content assist preferences of eclipse. But as far as I know, this is the default setting.