Teach getOwnerFunction() in KtParamter work with stubs
This commit is contained in:
@@ -173,10 +173,8 @@ public class KtParameter extends KtNamedDeclarationStub<KotlinParameterStub> 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();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<KotlinPlaceHolderStub<KtP
|
||||
public void removeParameter(@NotNull KtParameter parameter) {
|
||||
EditCommaSeparatedListHelper.INSTANCE.removeItem(parameter);
|
||||
}
|
||||
|
||||
public KtFunction getOwnerFunction() {
|
||||
PsiElement parent = getParentByStub();
|
||||
if (!(parent instanceof KtFunction)) return null;
|
||||
return (KtFunction) parent;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user