Convert member to extension: preserve visibility
#KT-29248 Fixed
This commit is contained in:
committed by
Mikhail Glukhikh
parent
e8a8bc89c9
commit
9c468ef2aa
+6
-1
@@ -267,7 +267,12 @@ class ConvertMemberToExtensionIntention : SelfTargetingRangeIntention<KtCallable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return processSingleDeclaration(element, allowExpected)
|
val classVisibility = element.containingClass()?.visibilityModifierType()
|
||||||
|
val (extension, bodyToSelect) = processSingleDeclaration(element, allowExpected)
|
||||||
|
if (classVisibility != null && extension.visibilityModifier() == null) {
|
||||||
|
extension.addModifier(classVisibility)
|
||||||
|
}
|
||||||
|
return extension to bodyToSelect
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun newTypeParameterList(member: KtCallableDeclaration): KtTypeParameterList? {
|
private fun newTypeParameterList(member: KtCallableDeclaration): KtTypeParameterList? {
|
||||||
|
|||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
internal class Foo {
|
||||||
|
private fun <caret>bar() {}
|
||||||
|
}
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
internal class Foo {
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Foo.bar() {}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
internal class Foo {
|
||||||
|
fun <caret>bar() {}
|
||||||
|
}
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
internal class Foo {
|
||||||
|
}
|
||||||
|
|
||||||
|
internal fun Foo.bar() {}
|
||||||
+3
@@ -0,0 +1,3 @@
|
|||||||
|
private class Foo {
|
||||||
|
fun <caret>bar() {}
|
||||||
|
}
|
||||||
Vendored
+4
@@ -0,0 +1,4 @@
|
|||||||
|
private class Foo {
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun Foo.bar() {}
|
||||||
@@ -8703,6 +8703,11 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/declarations/convertMemberToExtension/private.kt");
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/private.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("privateInInternalClass.kt")
|
||||||
|
public void testPrivateInInternalClass() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/privateInInternalClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("protected.kt")
|
@TestMetadata("protected.kt")
|
||||||
public void testProtected() throws Exception {
|
public void testProtected() throws Exception {
|
||||||
runTest("idea/testData/intentions/declarations/convertMemberToExtension/protected.kt");
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/protected.kt");
|
||||||
@@ -8713,6 +8718,16 @@ public class IntentionTestGenerated extends AbstractIntentionTest {
|
|||||||
runTest("idea/testData/intentions/declarations/convertMemberToExtension/public.kt");
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/public.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("publicInInternalClass.kt")
|
||||||
|
public void testPublicInInternalClass() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/publicInInternalClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("publicInPrivateClass.kt")
|
||||||
|
public void testPublicInPrivateClass() throws Exception {
|
||||||
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/publicInPrivateClass.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("secondaryConstructor.kt")
|
@TestMetadata("secondaryConstructor.kt")
|
||||||
public void testSecondaryConstructor() throws Exception {
|
public void testSecondaryConstructor() throws Exception {
|
||||||
runTest("idea/testData/intentions/declarations/convertMemberToExtension/secondaryConstructor.kt");
|
runTest("idea/testData/intentions/declarations/convertMemberToExtension/secondaryConstructor.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user