未验证 提交 cbbdec58 编写于 作者: T Toshiaki Kameyama 提交者: GitHub

Change Signature: enable on primary constructor keyword (#2482)

#KT-19744 Fixed
上级 957a9277
...@@ -79,6 +79,7 @@ class KotlinChangeSignatureHandler : ChangeSignatureHandler { ...@@ -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 ->
......
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")
}
\ No newline at end of file
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()
}
\ No newline at end of file
...@@ -808,6 +808,20 @@ class KotlinChangeSignatureTest : KotlinLightCodeInsightFixtureTestCase() { ...@@ -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\"")) }
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册