mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
optimize imports: instance members should not conflict via static imports (IDEA-167039)
This commit is contained in:
@@ -314,7 +314,10 @@ public class ImportHelper{
|
||||
else if ((aClass = facade.findClass(onDemand, resolveScope)) != null) { // import static foo.package1.Class1.*;
|
||||
if (isStatic) {
|
||||
PsiMember[][] membersArray = {aClass.getInnerClasses(), aClass.getMethods(), aClass.getFields()};
|
||||
Set<String> set = Arrays.stream(membersArray).flatMap(Arrays::stream).map(PsiMember::getName).collect(toSet());
|
||||
Set<String> set = Arrays.stream(membersArray)
|
||||
.flatMap(Arrays::stream)
|
||||
.filter(member -> member.hasModifierProperty(PsiModifier.STATIC))
|
||||
.map(PsiMember::getName).collect(toSet());
|
||||
classNames.put(onDemand, set);
|
||||
}
|
||||
else {
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
import static java.lang.String.format;
|
||||
import static java.lang.String.valueOf;
|
||||
import static java.lang.String.copyValueOf;
|
||||
|
||||
class OptimizeImport {
|
||||
public static void main(String[] args) {
|
||||
format("foo");
|
||||
valueOf(1);
|
||||
copyValueOf(new char[0]);
|
||||
}
|
||||
}
|
||||
+9
@@ -0,0 +1,9 @@
|
||||
import static java.lang.String.*;
|
||||
|
||||
class OptimizeImport {
|
||||
public static void main(String[] args) {
|
||||
format("foo");
|
||||
valueOf(1);
|
||||
copyValueOf(new char[0]);
|
||||
}
|
||||
}
|
||||
@@ -53,6 +53,10 @@ public class OptimizeImportsTest extends OptimizeImportsTestCase {
|
||||
doTest();
|
||||
}
|
||||
|
||||
public void testExcludeNonStaticElementsFromStaticConflictingMembers() throws Exception {
|
||||
doTest();
|
||||
}
|
||||
|
||||
private void doTest() throws Exception {
|
||||
doTest(".java");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user