Community
Participate
Working Groups
Build Identifier: 20110615-0604 I've seen some times that imports are not ordered according to the order registered in Java->Code Style->Organize Reproducible: Always Steps to Reproduce: 1. Using the default ordering of java javax org com Organize the following imports. Notice that the junit import is on top instead of the org import import junit.framework.TestCase; import org.w3c.dom.Comment; public class Test { Comment c = null; TestCase fs = null; } 2. If I change the order to (switch org and javax) it imports the classes in the right order java org javax com import org.w3c.dom.Comment; import junit.framework.TestCase; public class Test { Comment c = null; TestCase fs = null; } I have only been able to verify it with imports from the junit package.
The "best" match for junit is considered to be "javax". So the junit entry is located relative to the javax entry. Why do you expect "import org.w3c.dom.Comment;" before "import junit.framework.TestCase;" ?
Hi I have the same issue. I would expect that all the entries in the default ordering configuration are at the top. And after all the default ordering entries all others appear. So for default ordering: java com I get: import java.util.List; import org.junit.Test; import com.mycompany.AnyClass; But I would expect: import java.util.List; import com.mycompany.AnyClass; import org.junit.Test;
I would like to stress this problem again. Real problem is when people in same team work in different IDEs: Eclispe, Idea, NetBeans,... - and each IDE try to fix imports order. It results in lots of merging conflicts. It becomes quite difficult to have imports organized with no pain. When IDE prevents people from effective collaboration, teams are forced to use one IDE, and it is not always Eclipse. I also would like to comment on Oliver's post: >> The "best" match for junit is considered to be "javax". So the junit entry is located relative to the javax entry. When I adjust "Organize Imports" settings (add or edit) Eclipse does not allow to enter something like regular expression, it forces me to select valid package. So "best match" between junit and javax is not acceptable. It should be "starting with" partial match. "Organize Imports" should have a predictable outcome, now it is not (or very not obvious).
Here https://github.com/checkstyle/checkstyle/issues/1448#issuecomment-123830773 is the analysis of the problem that shows that Eclipse has a problem in such a simple option.
I have just updated to Eclipse Mars version and it looks like the problem is solved.
(In reply to Aleksandr Ivanov from comment #5) > I have just updated to Eclipse Mars version and it looks like the problem is > solved. Thanks, marking as FIXED.