3

My eclipse is configured so that when I save the java source file, it automatically inserts the missing import declarations. Except when the reference is ambiguous. Fpr instance, the most annoying ambiguity is with List<T> - both java.util and java.awt declare it. Here eclipse demands manual resolution.

I was wondering if it was possible to configure somewhere that whenever List<T> is used then java.util should be imported. Or alternatively, since I am not using java.awt, I could just remove it from the list of possible suggestions.

Any ideas?

Thanks.

mark
  • 59,016
  • 79
  • 296
  • 580
  • This sounds like a duplicate of http://stackoverflow.com/questions/10019698/exclude-packages-from-eclipses-organize-imports – E-Riz Jun 18 '12 at 14:41
  • Very similar indeed, missed that one. – mark Jun 18 '12 at 18:10
  • @E-Riz - please, arrange your comment as an answer so I could credit you for it, since it seems to be the closest thing to the solution. – mark Jun 19 '12 at 08:27

3 Answers3

1

This sounds like a possible duplicate of Exclude packages from Eclipse's organize imports. Basically, you want to change your Type Filters preference to exclude java.awt.* packages. Keep in mind that doing so will make things harder/confusing if you ever try to write AWT/Swing code.

Community
  • 1
  • 1
E-Riz
  • 31,431
  • 9
  • 97
  • 134
0

One thing that pops into my mind is altering the class template in the preferences to include the line:

import java.util.List

Unless you are going to use the AWT version of a List, or care about unused import statements, that should solve this annoying issue ..

Protostome
  • 5,569
  • 5
  • 30
  • 45
0

Manually invoke Organize Imports and it will ask you when an ambiguity is found.

nitind
  • 19,089
  • 4
  • 34
  • 43