Rename: Allow renaming class by constructor delegation call referencing primary constructor

#KT-8860 Fixed
This commit is contained in:
Alexey Sedunov
2016-05-24 19:57:28 +03:00
parent e89e809dc7
commit ff4c16d342
6 changed files with 20 additions and 5 deletions
+1
View File
@@ -175,6 +175,7 @@
- [`KT-7851`](https://youtrack.jetbrains.com/issue/KT-7851) Respect naming conventions in automatic variable rename
###### Issues fixed
- [`KT-8860`](https://youtrack.jetbrains.com/issue/KT-8860) Allow renaming class by constructor delegation call referencing primary constructor
- [`KT-9156`](https://youtrack.jetbrains.com/issue/KT-9156) Quote non-identifier names in Kotlin references
- [`KT-9157`](https://youtrack.jetbrains.com/issue/KT-9157) Fixed in-place rename of Kotlin expression referring Java declaration
- [`KT-10713`](https://youtrack.jetbrains.com/issue/KT-10713) Skip read-only declarations when renaming parameters
@@ -25,10 +25,7 @@ import com.intellij.psi.PsiFile
import com.intellij.psi.util.PsiTreeUtil
import com.intellij.refactoring.rename.RenameHandler
import org.jetbrains.kotlin.idea.codeInsight.CodeInsightUtils
import org.jetbrains.kotlin.psi.KtBlockExpression
import org.jetbrains.kotlin.psi.KtParameterList
import org.jetbrains.kotlin.psi.KtSecondaryConstructor
import org.jetbrains.kotlin.psi.KtValueArgumentList
import org.jetbrains.kotlin.psi.*
class RenameOnSecondaryConstructorHandler : RenameHandler {
@@ -40,7 +37,7 @@ class RenameOnSecondaryConstructorHandler : RenameHandler {
val element = PsiTreeUtil.findElementOfClassAtOffsetWithStopSet(
file, editor.caretModel.offset, KtSecondaryConstructor::class.java, false,
KtBlockExpression::class.java, KtValueArgumentList::class.java, KtParameterList::class.java
KtBlockExpression::class.java, KtValueArgumentList::class.java, KtParameterList::class.java, KtConstructorDelegationCall::class.java
)
return element != null
}
@@ -0,0 +1,3 @@
class Bar constructor(p: Int) {
constructor(p: Int) : this(p + 1)
}
@@ -0,0 +1,3 @@
class Foo constructor(p: Int) {
constructor(p: Int) : /*rename*/this(p + 1)
}
@@ -0,0 +1,5 @@
{
"type": "MARKED_ELEMENT",
"mainFile": "test.kt",
"newName": "Bar"
}
@@ -125,6 +125,12 @@ public class RenameTestGenerated extends AbstractRenameTest {
doTest(fileName);
}
@TestMetadata("renameClassByRefInConstructorDelegationCall/renameClassByRefInConstructorDelegationCall.test")
public void testRenameClassByRefInConstructorDelegationCall_RenameClassByRefInConstructorDelegationCall() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/renameClassByRefInConstructorDelegationCall/renameClassByRefInConstructorDelegationCall.test");
doTest(fileName);
}
@TestMetadata("renameClassWithAutoVarConventions/renameClassWithAutoVarConventions.test")
public void testRenameClassWithAutoVarConventions_RenameClassWithAutoVarConventions() throws Exception {
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/rename/renameClassWithAutoVarConventions/renameClassWithAutoVarConventions.test");