Search code examples
eclipsecontent-assistimport

Can you configure eclipse to code assist some imports rather than others


Eclipse sometimes automatically inserts imports into my java code, but it often gets them wrong. Are there ways to configure the guesses that it makes. I would like to tell it to always import java.util.List rather than java.awt.list for example. There are also a bunch of others that it gets wrong including Pattern, Matcher, Logger, Node, and Element. All of which I have a preferred class that I use all the time but there are many other classes with the same name.


Solution

  • You can configure certain imports to be hidden from the content assist dialog via Window | Preferences | Java | Appearance | Type Filters.

    For example, adding a filter such as java.awt.* would hide all types from the awt packages.

    However this is probably only useful if you don't use those classes at all, as it won't show any content assist information for them. I haven't come across a way to prefer certain packages or class names over others.

    Under Window | Preferences | Java | Editor | Content Assist | Favorites there are some options for adding types and members, but I think these only apply to static members.