Rename: Support inplace rename on type parameters
This commit is contained in:
@@ -18,6 +18,10 @@ package org.jetbrains.kotlin.psi;
|
|||||||
|
|
||||||
import com.intellij.lang.ASTNode;
|
import com.intellij.lang.ASTNode;
|
||||||
import com.intellij.psi.PsiElement;
|
import com.intellij.psi.PsiElement;
|
||||||
|
import com.intellij.psi.search.GlobalSearchScope;
|
||||||
|
import com.intellij.psi.search.LocalSearchScope;
|
||||||
|
import com.intellij.psi.search.SearchScope;
|
||||||
|
import com.intellij.psi.util.PsiTreeUtil;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.kotlin.lexer.KtTokens;
|
import org.jetbrains.kotlin.lexer.KtTokens;
|
||||||
@@ -82,4 +86,11 @@ public class KtTypeParameter extends KtNamedDeclarationStub<KotlinTypeParameterS
|
|||||||
public KtTypeReference getExtendsBound() {
|
public KtTypeReference getExtendsBound() {
|
||||||
return getStubOrPsiChild(KtStubElementTypes.TYPE_REFERENCE);
|
return getStubOrPsiChild(KtStubElementTypes.TYPE_REFERENCE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NotNull
|
||||||
|
@Override
|
||||||
|
public SearchScope getUseScope() {
|
||||||
|
KtTypeParameterListOwner owner = PsiTreeUtil.getParentOfType(this, KtTypeParameterListOwner.class);
|
||||||
|
return owner != null ? new LocalSearchScope(owner) : GlobalSearchScope.EMPTY_SCOPE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,6 +51,7 @@ class KotlinRefactoringSupportProvider : RefactoringSupportProvider() {
|
|||||||
|
|
||||||
override fun isInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean {
|
override fun isInplaceRenameAvailable(element: PsiElement, context: PsiElement?): Boolean {
|
||||||
when (element) {
|
when (element) {
|
||||||
|
is KtTypeParameter -> return true
|
||||||
is KtProperty -> {
|
is KtProperty -> {
|
||||||
if (element.isLocal) return true
|
if (element.isLocal) return true
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user