Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OrganizeImports fixed for clashing star imports. #4561

Merged
merged 1 commit into from
Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -1278,9 +1278,8 @@ private CompilationUnitTree addImports(CompilationUnitTree cut, List<? extends I
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;
}
}
}
Expand Down