Create function quick fix: fix visibility from inline method #KT-25228 Fixed
This commit is contained in:
committed by
Alexey Sedunov
parent
e2945b1d12
commit
dc57887a4d
+11
-1
@@ -275,7 +275,17 @@ sealed class CreateCallableFromCallActionFactory<E : KtExpression>(
|
|||||||
} else {
|
} else {
|
||||||
TypeInfo(fullCallExpression, Variance.OUT_VARIANCE)
|
TypeInfo(fullCallExpression, Variance.OUT_VARIANCE)
|
||||||
}
|
}
|
||||||
return FunctionInfo(name, receiverType, returnType, possibleContainers, parameters, typeParameters)
|
val parentFunction = expression.getStrictParentOfType<KtNamedFunction>()
|
||||||
|
val modifierList = if (parentFunction?.hasModifier(KtTokens.INLINE_KEYWORD) == true) {
|
||||||
|
when {
|
||||||
|
parentFunction.isPublic -> KtPsiFactory(expression).createModifierList(KtTokens.PUBLIC_KEYWORD)
|
||||||
|
parentFunction.isProtected() -> KtPsiFactory(expression).createModifierList(KtTokens.PROTECTED_KEYWORD)
|
||||||
|
else -> null
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
null
|
||||||
|
}
|
||||||
|
return FunctionInfo(name, receiverType, returnType, possibleContainers, parameters, typeParameters, modifierList = modifierList)
|
||||||
}
|
}
|
||||||
|
|
||||||
object Default : Function()
|
object Default : Function()
|
||||||
|
|||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
internal inline fun f() {
|
||||||
|
<caret>g()
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
internal inline fun f() {
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun g() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
private inline fun f() {
|
||||||
|
<caret>g()
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
private inline fun f() {
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
|
||||||
|
private fun g() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
protected inline fun f() {
|
||||||
|
<caret>g()
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
protected inline fun f() {
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
|
||||||
|
protected fun g() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -0,0 +1,6 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
inline fun f() {
|
||||||
|
<caret>g()
|
||||||
|
}
|
||||||
|
}
|
||||||
+10
@@ -0,0 +1,10 @@
|
|||||||
|
// "Create function 'g'" "true"
|
||||||
|
class C {
|
||||||
|
inline fun f() {
|
||||||
|
g()
|
||||||
|
}
|
||||||
|
|
||||||
|
fun g() {
|
||||||
|
TODO("not implemented") //To change body of created functions use File | Settings | File Templates.
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -3101,6 +3101,26 @@ public class QuickFixTestGenerated extends AbstractQuickFixTest {
|
|||||||
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funExtraArgs.kt");
|
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funExtraArgs.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInInlineInternalFun.kt")
|
||||||
|
public void testFunInInlineInternalFun() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funInInlineInternalFun.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInInlinePrivateFun.kt")
|
||||||
|
public void testFunInInlinePrivateFun() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funInInlinePrivateFun.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInInlineProtectedFun.kt")
|
||||||
|
public void testFunInInlineProtectedFun() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funInInlineProtectedFun.kt");
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funInInlinePublicFun.kt")
|
||||||
|
public void testFunInInlinePublicFun() throws Exception {
|
||||||
|
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funInInlinePublicFun.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("funMissingArgs.kt")
|
@TestMetadata("funMissingArgs.kt")
|
||||||
public void testFunMissingArgs() throws Exception {
|
public void testFunMissingArgs() throws Exception {
|
||||||
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funMissingArgs.kt");
|
runTest("idea/testData/quickfix/createFromUsage/createFunction/call/funMissingArgs.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user