- Navigate to Preferences by clicking on the Window -> Preferences Menu Item
- Navigate to Java -> Editor -> Content Assist -> Favorites using the menu tree (or search for Favorites using the search bar at the top)
- Click the New Type button
- Type in the name of the Class that has static methods that you would like to be used when using Eclipse's Content Assist / Code Completion (eg Assert)
- Click on the Browse button which will bring up the Open Type Dialog using what you entered previously as the search criteria
- Find the class that you would like to add, and then click Okay on the Open Type Dialog
- Then Click Okay on the New Type Favorite Dialog.
If this helps, pay it forward....
6 comments:
Hey, Carlus! I stumbled on this Eclipse feature a while ago but had forgotten about it. Thanks for reminding me.
One question: setting this content assist helps with ctrl-space completion, but it apparently doesn't help with Source -> Organize Imports. I know, who would do things this way? But sometimes it would be useful. Do you know if there's a separate setting for Organize Imports? Can you tell me if you do (smile)?
Funny you should mention this. I just stumbled across a post that tells exactly how to do just what you are looking for.
Organizing Static Imports
Actually, that only works if there's a static import already there. Then Eclipse will use the .* form to statically import everything from the specified class.
Unfortunately, it won't add new static imports.
I figured out when this is a problem for me: when I introduce a static-method call with a template (like "ear" for an EasyMock "expect().andReturn()".)
Thanks for sharing your post and it was superb .I would like to hear more from you in future too.
Great tip!! Thank you.
Loving it, just used this my new Mockito unit tests! Thanks
Post a Comment