views:

59

answers:

2

Sometimes I put the class name in the comments of methods or class just for referencing. But eclipse does the import automatically and leaves an import statement in the file which causes "unused import" checkstyle errors later. Is there some configuration I can change to avoid eclipse automatically importing when I type the class name in the comments?

A: 

In my case eclipse never imports anything if I type a class name in a comment. Maybe you have enabled this behaviour through a setting change yourself? Normally eclipse would only react to same event you triggered (pressing ctrl+space or strl+1 or something like that) and would not generate an import if you just type in a name.

Arne
He means Javadoc comments. If you include e.g. `{@link File}` and use _Organize imports_ Eclipse will add an import.
musiKk
+2  A: 

People don't agree whether this is a bug or not. Javadoc needs the imports to create appropriate links. I'd say checkstyle should provide an option (and Eclipse maybe too) to change change the warning.

There are two relevant bug reports:

musiKk