diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/OrganizeImportsTest.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/OrganizeImportsTest.java index 317f74db10e0..7c651dd8353b 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/OrganizeImportsTest.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/OrganizeImportsTest.java @@ -49,4 +49,27 @@ public void testSimple() throws Exception { " List l = new ArrayList();\n" + "}\n"); } + + public void testClashing() throws Exception { + HintTest.create() + .input("package test;\n" + + "import java.awt.*;\n" + + "import java.util.List;\n" + + "import java.util.*;\n" + + "public class Test {\n" + + " List l = new ArrayList();\n" + + " Button b;\n" + + "}\n") + .run(OrganizeImports.class) + .findWarning("2:0-2:22:verifier:MSG_OragnizeImports") + .applyFix() + .assertOutput("package test;\n" + + "import java.awt.*;\n" + + "import java.util.*;\n" + + "import java.util.List;\n" + + "public class Test {\n" + + " List l = new ArrayList();\n" + + " Button b;\n" + + "}\n"); + } } diff --git a/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java b/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java index c736797aa6c5..6b0cc4b9e77e 100644 --- a/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java +++ b/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java @@ -1278,9 +1278,8 @@ private CompilationUnitTree addImports(CompilationUnitTree cut, List