mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-04-19 21:11:28 +07:00
provide types for Java fields
This commit is contained in:
@@ -30,13 +30,21 @@ public class PyJavaTypeProvider extends PyTypeProviderBase {
|
||||
}
|
||||
if (referenceTarget instanceof PsiMethod) {
|
||||
PsiMethod method = (PsiMethod) referenceTarget;
|
||||
final PsiType type = method.getReturnType();
|
||||
if (type instanceof PsiClassType) {
|
||||
final PsiClassType classType = (PsiClassType)type;
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass != null) {
|
||||
return new PyJavaClassType(psiClass);
|
||||
}
|
||||
return asPyType(method.getReturnType());
|
||||
}
|
||||
if (referenceTarget instanceof PsiField) {
|
||||
return asPyType(((PsiField)referenceTarget).getType());
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private static PyType asPyType(PsiType type) {
|
||||
if (type instanceof PsiClassType) {
|
||||
final PsiClassType classType = (PsiClassType)type;
|
||||
final PsiClass psiClass = classType.resolve();
|
||||
if (psiClass != null) {
|
||||
return new PyJavaClassType(psiClass);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
|
||||
@@ -64,6 +64,12 @@ public class PyToJavaResolveTest extends ResolveTestCase {
|
||||
Assert.assertEquals("size", ((PsiMethod) target).getName());
|
||||
}
|
||||
|
||||
public void testFieldType() throws Exception {
|
||||
PsiElement target = resolve();
|
||||
Assert.assertTrue(target instanceof PsiMethod);
|
||||
Assert.assertEquals("println", ((PsiMethod) target).getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getTestDataPath() {
|
||||
return PythonTestUtil.getTestDataPath() + "/resolve/pyToJava/";
|
||||
|
||||
2
python/testData/resolve/pyToJava/FieldType.py
Normal file
2
python/testData/resolve/pyToJava/FieldType.py
Normal file
@@ -0,0 +1,2 @@
|
||||
from java.lang import System as javasystem
|
||||
javasystem.out.p<ref>rintln("Hello")
|
||||
Reference in New Issue
Block a user