Change Signature: enable on primary constructor keyword (#2482)
#KT-19744 Fixed
This commit is contained in:
committed by
GitHub
parent
957a927790
commit
cbbdec5898
+1
@@ -79,6 +79,7 @@ class KotlinChangeSignatureHandler : ChangeSignatureHandler {
|
|||||||
) return elementParent
|
) return elementParent
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (elementParent is KtPrimaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent
|
||||||
if (elementParent is KtSecondaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent
|
if (elementParent is KtSecondaryConstructor && elementParent.getConstructorKeyword() === element) return elementParent
|
||||||
|
|
||||||
element.getStrictParentOfType<KtParameterList>()?.let { parameterList ->
|
element.getStrictParentOfType<KtParameterList>()?.let { parameterList ->
|
||||||
|
|||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
open class A internal constructor(s: String) {
|
||||||
|
constructor(a: Int) : this("foo") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B : A {
|
||||||
|
constructor() : super("foo") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class C : A {
|
||||||
|
constructor() : super("foo") {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D : A("foo") {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A("foo")
|
||||||
|
}
|
||||||
+25
@@ -0,0 +1,25 @@
|
|||||||
|
open class A internal <caret>constructor() {
|
||||||
|
constructor(a: Int) : this() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class B : A {
|
||||||
|
constructor() : super() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
open class C : A {
|
||||||
|
constructor() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class D : A() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {
|
||||||
|
A()
|
||||||
|
}
|
||||||
+14
@@ -808,6 +808,20 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun testPrimaryConstructorOnConstructorKeyword() = doTest {
|
||||||
|
val defaultValueForCall = KtPsiFactory(project).createExpression("\"foo\"")
|
||||||
|
addParameter(
|
||||||
|
KotlinParameterInfo(
|
||||||
|
originalBaseFunctionDescriptor,
|
||||||
|
-1,
|
||||||
|
"s",
|
||||||
|
KotlinTypeInfo(false, BUILT_INS.stringType),
|
||||||
|
null,
|
||||||
|
defaultValueForCall
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
fun testJavaConstructorInDelegationCall() {
|
fun testJavaConstructorInDelegationCall() {
|
||||||
doJavaTest { newParameters.add(ParameterInfoImpl(-1, "s", stringPsiType, "\"foo\"")) }
|
doJavaTest { newParameters.add(ParameterInfoImpl(-1, "s", stringPsiType, "\"foo\"")) }
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user