From 39e6b893a71c1b98586aba177461b03a85b17a50 Mon Sep 17 00:00:00 2001 From: Nikolay Krasko Date: Wed, 20 Apr 2016 20:26:41 +0300 Subject: [PATCH] Teach getOwnerFunction() in KtParamter work with stubs --- .../src/org/jetbrains/kotlin/psi/KtParameter.java | 8 +++----- .../src/org/jetbrains/kotlin/psi/KtParameterList.java | 7 +++++++ 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameter.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameter.java index 98a33cc04d3..20b8f9cd756 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameter.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameter.java @@ -173,10 +173,8 @@ public class KtParameter extends KtNamedDeclarationStub imp @Nullable public KtFunction getOwnerFunction() { - PsiElement parent = getParent(); - if (parent == null) return null; - PsiElement grandparent = parent.getParent(); - if (!(grandparent instanceof KtFunction)) return null; - return (KtFunction) grandparent; + PsiElement parent = getParentByStub(); + if (!(parent instanceof KtParameterList)) return null; + return ((KtParameterList) parent).getOwnerFunction(); } } diff --git a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameterList.java b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameterList.java index 53f60a742aa..06842f35fdb 100644 --- a/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameterList.java +++ b/compiler/frontend/src/org/jetbrains/kotlin/psi/KtParameterList.java @@ -17,6 +17,7 @@ package org.jetbrains.kotlin.psi; import com.intellij.lang.ASTNode; +import com.intellij.psi.PsiElement; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub; @@ -61,4 +62,10 @@ public class KtParameterList extends KtElementImplStub