Rename: Do not search text occurrences of local declarations
#KT-23838 Fixed
This commit is contained in:
@@ -59,6 +59,12 @@ abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
|
||||
return references
|
||||
}
|
||||
|
||||
override fun getElementToSearchInStringsAndComments(element: PsiElement): PsiElement? {
|
||||
val unwrapped = element?.unwrapped ?: return null
|
||||
if ((unwrapped is KtDeclaration) && KtPsiUtil.isLocal(unwrapped as KtDeclaration)) return null
|
||||
return element
|
||||
}
|
||||
|
||||
override fun getQualifiedNameAfterRename(element: PsiElement, newName: String, nonJava: Boolean): String? {
|
||||
if (!nonJava) return newName
|
||||
|
||||
|
||||
@@ -59,6 +59,12 @@ abstract class RenameKotlinPsiProcessor : RenamePsiElementProcessor() {
|
||||
return references
|
||||
}
|
||||
|
||||
override fun getElementToSearchInStringsAndComments(element: PsiElement?): PsiElement? {
|
||||
val unwrapped = element?.unwrapped ?: return null
|
||||
if ((unwrapped is KtDeclaration) && KtPsiUtil.isLocal(unwrapped as KtDeclaration)) return null
|
||||
return element
|
||||
}
|
||||
|
||||
override fun getQualifiedNameAfterRename(element: PsiElement, newName: String?, nonJava: Boolean): String? {
|
||||
if (!nonJava) return newName
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
fun foo(x: Int) {
|
||||
val <caret>y = x + 1
|
||||
val z = y + 1
|
||||
// y
|
||||
val s = "y"
|
||||
}
|
||||
@@ -0,0 +1,6 @@
|
||||
fun foo(x: Int) {
|
||||
val w = x + 1
|
||||
val z = w + 1
|
||||
// y
|
||||
val s = "y"
|
||||
}
|
||||
@@ -174,6 +174,10 @@ class InplaceRenameTest : LightPlatformCodeInsightTestCase() {
|
||||
doTestMemberInplaceRename("`object`")
|
||||
}
|
||||
|
||||
fun testNoTextUsagesForLocalVar() {
|
||||
doTestMemberInplaceRename("w")
|
||||
}
|
||||
|
||||
private fun doTestImplicitLambdaParameter(newName: String) {
|
||||
configureByFile(getTestName(false) + ".kt")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user