Rename: Support inplace rename on type parameters

This commit is contained in:
Alexey Sedunov
2016-08-30 21:06:03 +03:00
parent 34c268b08b
commit 4e2c4d941d
2 changed files with 12 additions and 0 deletions
@@ -18,6 +18,10 @@ package org.jetbrains.kotlin.psi;
import com.intellij.lang.ASTNode;
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.Nullable;
import org.jetbrains.kotlin.lexer.KtTokens;
@@ -82,4 +86,11 @@ public class KtTypeParameter extends KtNamedDeclarationStub<KotlinTypeParameterS
public KtTypeReference getExtendsBound() {
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 {
when (element) {
is KtTypeParameter -> return true
is KtProperty -> {
if (element.isLocal) return true
}