Enable Type Hierarchy for Kotlin classes referenced by non-Kotlin code #KT-4414 Fixed

This commit is contained in:
Alexey Sedunov
2014-01-27 16:01:58 +04:00
parent 774e6e23e9
commit 8a0867a9c3
11 changed files with 41 additions and 3 deletions
@@ -32,7 +32,6 @@ import com.intellij.psi.util.PsiTreeUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.jet.lang.descriptors.FunctionDescriptor;
import org.jetbrains.jet.lang.psi.JetClassOrObject;
import org.jetbrains.jet.lang.psi.JetFile;
import org.jetbrains.jet.lang.psi.JetNamedFunction;
import org.jetbrains.jet.lang.resolve.BindingContext;
import org.jetbrains.jet.lang.types.JetType;
@@ -45,7 +44,6 @@ import org.jetbrains.jet.renderer.DescriptorRenderer;
import java.util.Collection;
public class KotlinTypeHierarchyProvider extends JavaTypeHierarchyProvider {
@Override
public PsiElement getTarget(@NotNull DataContext dataContext) {
Project project = PlatformDataKeys.PROJECT.getData(dataContext);
@@ -54,7 +52,7 @@ public class KotlinTypeHierarchyProvider extends JavaTypeHierarchyProvider {
Editor editor = PlatformDataKeys.EDITOR.getData(dataContext);
if (editor != null) {
PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(editor.getDocument());
if (!(file instanceof JetFile)) return null;
if (file == null) return null;
if (!JetPluginUtil.isInSource(file)) return null;
if (JetPluginUtil.isKtFileInGradleProjectInWrongFolder(file)) return null;
@@ -0,0 +1,3 @@
public class MyClass extends <caret>KotlinClass {
}
@@ -0,0 +1 @@
public open class KotlinClass
@@ -0,0 +1,5 @@
<node text="Object (java.lang)">
<node text="KotlinClass ()" base="true">
<node text="MyClass ()"/>
</node>
</node>
@@ -0,0 +1,3 @@
public class JavaClass {
}
@@ -0,0 +1 @@
public open class KotlinClass: <caret>JavaClass()
@@ -0,0 +1,5 @@
<node text="Object (java.lang)">
<node text="JavaClass ()" base="true">
<node text="KotlinClass ()"/>
</node>
</node>
@@ -0,0 +1 @@
public open class BaseClass
@@ -0,0 +1 @@
public open class DerivedClass: <caret>BaseClass()
@@ -0,0 +1,5 @@
<node text="Object (java.lang)">
<node text="BaseClass ()" base="true">
<node text="DerivedClass ()"/>
</node>
</node>
@@ -128,6 +128,11 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/JavaFromKotlin");
}
@TestMetadata("JavaFromKotlinByRef")
public void testJavaFromKotlinByRef() throws Exception {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/JavaFromKotlinByRef");
}
@TestMetadata("JavaFromKotlinForKotlinClass")
public void testJavaFromKotlinForKotlinClass() throws Exception {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/JavaFromKotlinForKotlinClass");
@@ -148,6 +153,16 @@ public class HierarchyTestGenerated extends AbstractHierarchyTest {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/KotlinFromJava");
}
@TestMetadata("KotlinFromJavaByRef")
public void testKotlinFromJavaByRef() throws Exception {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/KotlinFromJavaByRef");
}
@TestMetadata("KotlinFromKotlinByRef")
public void testKotlinFromKotlinByRef() throws Exception {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/KotlinFromKotlinByRef");
}
@TestMetadata("Object")
public void testObject() throws Exception {
doTypeClassHierarchyTest("idea/testData/hierarchy/class/type/Object");