Fix KNPE in "introduce variable", add some name conflict introduce tests
So #KT-21530 Fixed
This commit is contained in:
+1
-1
@@ -529,7 +529,7 @@ object KotlinIntroduceVariableHandler : RefactoringActionHandler {
|
|||||||
else {
|
else {
|
||||||
expression.parent as KtElement
|
expression.parent as KtElement
|
||||||
}
|
}
|
||||||
var commonContainer = commonParent.getContainer()!!
|
var commonContainer = commonParent as? KtFile ?: commonParent.getContainer()!!
|
||||||
if (commonContainer != container && container.isAncestor(commonContainer, true)) {
|
if (commonContainer != container && container.isAncestor(commonContainer, true)) {
|
||||||
commonContainer = container
|
commonContainer = container
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,6 @@
|
|||||||
|
// EXTRACTION_TARGET: property with initializer
|
||||||
|
|
||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
val f = <selection>test()</selection> + "456"
|
||||||
|
val x = test()
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
// EXTRACTION_TARGET: property with initializer
|
||||||
|
|
||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
private val s = test()
|
||||||
|
|
||||||
|
val f = s + "456"
|
||||||
|
val x = s
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
open class First(val s: String)
|
||||||
|
object Second : First(<selection>test()</selection> + "456")
|
||||||
|
|
||||||
|
fun foo(test: String) {
|
||||||
|
val x = test()
|
||||||
|
}
|
||||||
+11
@@ -0,0 +1,11 @@
|
|||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
open class First(val s: String)
|
||||||
|
|
||||||
|
val test1 = test()
|
||||||
|
|
||||||
|
object Second : First(test1 + "456")
|
||||||
|
|
||||||
|
fun foo(test: String) {
|
||||||
|
val x = test1
|
||||||
|
}
|
||||||
@@ -0,0 +1,4 @@
|
|||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
val f = <selection>test()</selection> + "456"
|
||||||
|
val x = test()
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
val test = test()
|
||||||
|
val f = test + "456"
|
||||||
|
val x = test
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
val f = <selection>test()</selection> + "456"
|
||||||
|
|
||||||
|
fun foo(test: String) {
|
||||||
|
val x = test()
|
||||||
|
}
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
fun test() = "123"
|
||||||
|
|
||||||
|
val test1 = test()
|
||||||
|
val f = test1 + "456"
|
||||||
|
|
||||||
|
fun foo(test: String) {
|
||||||
|
val x = test1
|
||||||
|
}
|
||||||
+24
@@ -236,6 +236,24 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
|
|||||||
doIntroduceVariableTest(fileName);
|
doIntroduceVariableTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt21530_withConstructorParam.kt")
|
||||||
|
public void testKt21530_withConstructorParam() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/kt21530_withConstructorParam.kt");
|
||||||
|
doIntroduceVariableTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt21530_withGlobal.kt")
|
||||||
|
public void testKt21530_withGlobal() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/kt21530_withGlobal.kt");
|
||||||
|
doIntroduceVariableTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt21530_withParam.kt")
|
||||||
|
public void testKt21530_withParam() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/kt21530_withParam.kt");
|
||||||
|
doIntroduceVariableTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("LoopRange.kt")
|
@TestMetadata("LoopRange.kt")
|
||||||
public void testLoopRange() throws Exception {
|
public void testLoopRange() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/LoopRange.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceVariable/LoopRange.kt");
|
||||||
@@ -3173,6 +3191,12 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
|
|||||||
doIntroducePropertyTest(fileName);
|
doIntroducePropertyTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("kt21530.kt")
|
||||||
|
public void testKt21530() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/kt21530.kt");
|
||||||
|
doIntroducePropertyTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("primaryConstructorParameterReference.kt")
|
@TestMetadata("primaryConstructorParameterReference.kt")
|
||||||
public void testPrimaryConstructorParameterReference() throws Exception {
|
public void testPrimaryConstructorParameterReference() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/primaryConstructorParameterReference.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceProperty/primaryConstructorParameterReference.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user