Teach getOwnerFunction() in KtParamter work with stubs
This commit is contained in:
@@ -173,10 +173,8 @@ public class KtParameter extends KtNamedDeclarationStub<KotlinParameterStub> imp
|
|||||||
|
|
||||||
@Nullable
|
@Nullable
|
||||||
public KtFunction getOwnerFunction() {
|
public KtFunction getOwnerFunction() {
|
||||||
PsiElement parent = getParent();
|
PsiElement parent = getParentByStub();
|
||||||
if (parent == null) return null;
|
if (!(parent instanceof KtParameterList)) return null;
|
||||||
PsiElement grandparent = parent.getParent();
|
return ((KtParameterList) parent).getOwnerFunction();
|
||||||
if (!(grandparent instanceof KtFunction)) return null;
|
|
||||||
return (KtFunction) grandparent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.jetbrains.kotlin.psi;
|
package org.jetbrains.kotlin.psi;
|
||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
|
import com.intellij.psi.PsiElement;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
import org.jetbrains.kotlin.psi.stubs.KotlinPlaceHolderStub;
|
||||||
@@ -61,4 +62,10 @@ public class KtParameterList extends KtElementImplStub<KotlinPlaceHolderStub<KtP
|
|||||||
public void removeParameter(@NotNull KtParameter parameter) {
|
public void removeParameter(@NotNull KtParameter parameter) {
|
||||||
EditCommaSeparatedListHelper.INSTANCE.removeItem(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