I have some problems with eclipse.
if I use something like anyMap() in my source code, and press then CTRL + SHIFT + O no update in the import list will be done.
If I write something like: import static org.mockito.Matchers.* into my imports, the anyMap() is then known.
If press then CTRL + SHIFT + O because i had to import some other classes, the import static org.mockito.Matchers.* will be replaced by import static org.mockito.Matchers.anyMap
If I want to use then anyList(), i have to write the import import static org.mockito.Matchers.* by hand again.
I know this topic Can Eclipse the Organize Import (ctrl+shift+o) command's handling of static imports be modified? and the solution works fine, but is there also a possibility so eclipse automatically knows the static classes i wanna use?
Yes this is possible .. see this question :
Eclipse Optimize Imports to Include Static Imports
Check the Favorite preference section:
Window » Preferences » Java » Editor » Content Assist » Favorites
Click ‘New Type’ and add
org.mockito.Matcherslike so :Once you do that, you should have the corresponding entry there like so :
After that, if you type
anyMin the code and do a Ctrl+Space you will see that the static method is one of the content assist proposals. If you choose that, the corresponding import is automatically added :If you type something that matches nothing but the static, the import will automatically be added. For example if you typed
anyMapand then pressed Ctrl + Space the import will directly be added.