views:

114

answers:

1

The eclipse and checkstyle guys of you will surely now this problem: After organizing imports in eclipse with CTRL-SHIFT-o, each import will be on a separate line, without line-wraps.

If you configured checkstyle to warn if you have lines greater than 80 characters, it will probably warn about your imports. Normally I insert newlines at appropriate positions in the statement and everything is okay. But the next time someone uses the organize imports function of eclipse every import is on one line again.

The auto-linewrap of the eclipse formatter does not work with imports. So I wonder if there is another way of telling eclipse to linewrap huge import statements? Or is there a plugin to do this?

+1  A: 

Why not defining an exception for the LineLength Checkstyle rule (with the ignorePattern property) ?
That way, any line beginning with import would not raise that warning.

If that is not possible, you will need to define a custom code formatter (see this SO answer)

VonC
For consistency of the code. Doing this is a good workaround, but I wonder if there isn't a real solution to this problem!
ManuelFuenfrocken