mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-01-05 01:50:56 +07:00
add single static import: ensure accessible class (from reference) is chosen (IDEA-144708)
This commit is contained in:
@@ -169,6 +169,9 @@ public class AddSingleMemberStaticImportAction extends BaseElementAtCaretIntenti
|
||||
if (qResolved instanceof PsiVariable) {
|
||||
aClass = PsiUtil.resolveClassInClassTypeOnly(((PsiVariable)qResolved).getType());
|
||||
}
|
||||
else if (qResolved instanceof PsiClass) {
|
||||
aClass = (PsiClass)qResolved;
|
||||
}
|
||||
}
|
||||
}
|
||||
return aClass;
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
import foo.*;
|
||||
class Class2 {
|
||||
public static void main(String[] args) {
|
||||
Bar.f<caret>oo();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
import foo.*;
|
||||
|
||||
import static foo.Bar.foo;
|
||||
|
||||
class Class2 {
|
||||
public static void main(String[] args) {
|
||||
f<caret>oo();
|
||||
}
|
||||
}
|
||||
@@ -29,6 +29,12 @@ public class AddSingleStaticImportActionTest extends JavaCodeInsightFixtureTestC
|
||||
doTest("Add static import for 'impl.FooImpl.foo'");
|
||||
}
|
||||
|
||||
public void testInaccessibleSuper() {
|
||||
myFixture.addClass("package foo; class Foo {public static void foo(){}}");
|
||||
myFixture.addClass("package foo; public class Bar extends Foo {}");
|
||||
doTest("Add static import for 'foo.Bar.foo'");
|
||||
}
|
||||
|
||||
public void testInsideParameterizedReference() {
|
||||
myFixture.addClass("package foo; " +
|
||||
"public class Class1 {" +
|
||||
|
||||
Reference in New Issue
Block a user