mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Java static imports are not classified as imports in Find Usages (IDEA-180332)
This commit is contained in:
@@ -240,6 +240,8 @@ public class JavaUsageTypeProvider implements UsageTypeProviderEx {
|
||||
}
|
||||
}
|
||||
|
||||
if (PsiTreeUtil.getParentOfType(element, PsiImportStaticStatement.class, false) != null) return UsageType.CLASS_IMPORT;
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
import static <caret>Foo.STATIC_FIELD;
|
||||
public class StaticMethodCallInImport {
|
||||
}
|
||||
@@ -0,0 +1,4 @@
|
||||
import static <caret>Foo.staticMethod;
|
||||
class StaticMethodUsageInImport {
|
||||
{ staticMethod(); }
|
||||
}
|
||||
@@ -43,6 +43,16 @@ public class JavaUsageTypeProviderTest extends LightCodeInsightFixtureTestCase {
|
||||
assertUsageType(UsageType.CLASS_STATIC_MEMBER_ACCESS, myFixture.findClass("Foo"));
|
||||
}
|
||||
|
||||
public void testStaticFieldUsageInImport() {
|
||||
myFixture.configureByFiles("StaticFieldUsageInImport.java", "Foo.java");
|
||||
assertUsageType(UsageType.CLASS_IMPORT, myFixture.findClass("Foo"));
|
||||
}
|
||||
|
||||
public void testStaticMethodUsageInImport() {
|
||||
myFixture.configureByFiles("StaticMethodUsageInImport.java", "Foo.java");
|
||||
assertUsageType(UsageType.CLASS_IMPORT, myFixture.findClass("Foo"));
|
||||
}
|
||||
|
||||
private void assertUsageType(UsageType expected, PsiClass target) {
|
||||
UsageTarget[] targets = {new PsiElement2UsageTargetAdapter(target)};
|
||||
PsiElement element = myFixture.getReferenceAtCaretPositionWithAssertion().getElement();
|
||||
|
||||
Reference in New Issue
Block a user