Search in sources :

Example 1 with KtLightMethod

use of org.jetbrains.kotlin.asJava.elements.KtLightMethod in project kotlin by JetBrains.

the class KotlinCalleeMethodsTreeStructure method buildChildren.

@NotNull
@Override
protected Object[] buildChildren(@NotNull HierarchyNodeDescriptor descriptor) {
    PsiElement targetElement = getTargetElement(descriptor);
    // Kotlin class constructor invoked from Java code
    if (targetElement instanceof PsiMethod) {
        PsiMethod psiMethod = (PsiMethod) targetElement;
        if (psiMethod.isConstructor()) {
            PsiClass psiClass = psiMethod.getContainingClass();
            PsiElement navigationElement = psiClass != null ? psiClass.getNavigationElement() : null;
            if (navigationElement instanceof KtClass) {
                return buildChildrenByKotlinTarget(descriptor, (KtElement) navigationElement);
            }
        }
    }
    // Kotlin function or property invoked from Java code
    if (targetElement instanceof KtLightMethod) {
        return buildChildrenByKotlinTarget(descriptor, ((KtLightMethod) targetElement).getKotlinOrigin());
    }
    if (targetElement instanceof KtElement) {
        return buildChildrenByKotlinTarget(descriptor, (KtElement) targetElement);
    }
    CallHierarchyNodeDescriptor javaDescriptor = descriptor instanceof CallHierarchyNodeDescriptor ? (CallHierarchyNodeDescriptor) descriptor : ((KotlinCallHierarchyNodeDescriptor) descriptor).getJavaDelegate();
    return javaTreeStructure.getChildElements(javaDescriptor);
}
Also used : PsiMethod(com.intellij.psi.PsiMethod) PsiClass(com.intellij.psi.PsiClass) KtLightMethod(org.jetbrains.kotlin.asJava.elements.KtLightMethod) PsiElement(com.intellij.psi.PsiElement) CallHierarchyNodeDescriptor(com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

CallHierarchyNodeDescriptor (com.intellij.ide.hierarchy.call.CallHierarchyNodeDescriptor)1 PsiClass (com.intellij.psi.PsiClass)1 PsiElement (com.intellij.psi.PsiElement)1 PsiMethod (com.intellij.psi.PsiMethod)1 NotNull (org.jetbrains.annotations.NotNull)1 KtLightMethod (org.jetbrains.kotlin.asJava.elements.KtLightMethod)1