You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@netbeans.apache.org by db...@apache.org on 2022/08/30 07:56:54 UTC

[netbeans] branch master updated: OrganizeImports fixed for clashing star imports. (#4561)

This is an automated email from the ASF dual-hosted git repository.

dbalek pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/netbeans.git


The following commit(s) were added to refs/heads/master by this push:
     new d1349ac911 OrganizeImports fixed for clashing star imports. (#4561)
d1349ac911 is described below

commit d1349ac911fbeca53a4765359d8fddca5cfe333a
Author: Dusan Balek <du...@oracle.com>
AuthorDate: Tue Aug 30 09:56:42 2022 +0200

    OrganizeImports fixed for clashing star imports. (#4561)
---
 .../modules/java/hints/OrganizeImportsTest.java    | 23 ++++++++++++++++++++++
 .../api/java/source/GeneratorUtilities.java        |  3 +--
 2 files changed, 24 insertions(+), 2 deletions(-)

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 317f74db10..7c651dd835 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 class OrganizeImportsTest extends NbTestCase {
                               "     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 c736797aa6..6b0cc4b9e7 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 @@ public final class GeneratorUtilities {
                     if (sym.getKind().isClass() || sym.getKind().isInterface()) {
                         if (sym != element) {
                             explicitNamedImports.add(element);
+                            break;// break if explicitNameImport was added
                         }
-                        // break if explicitNameImport was added, or when the symbol is correctly resolved.
-                        break;
                     }
                 }
             }


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@netbeans.apache.org
For additional commands, e-mail: commits-help@netbeans.apache.org

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists