Introduce Parameter: Forbid inside of default values
This commit is contained in:
+4
@@ -377,6 +377,10 @@ open class KotlinIntroduceParameterHandler(
|
||||
showErrorHint(project, editor, "Introduce Parameter is not available inside of annotation entries", INTRODUCE_PARAMETER)
|
||||
return
|
||||
}
|
||||
if (elementAtCaret.getNonStrictParentOfType<KtParameter>() != null) {
|
||||
showErrorHint(project, editor, "Introduce Parameter is not available for default value", INTRODUCE_PARAMETER)
|
||||
return
|
||||
}
|
||||
|
||||
selectNewParameterContext(editor, file) { elements, targetParent ->
|
||||
val expression = ((elements.singleOrNull() as? KtBlockExpression)?.statements ?: elements).singleOrNull()
|
||||
|
||||
@@ -0,0 +1,3 @@
|
||||
fun foo(s: String = <caret>"abc") {
|
||||
|
||||
}
|
||||
@@ -0,0 +1 @@
|
||||
Introduce Parameter is not available for default value
|
||||
+6
@@ -3512,6 +3512,12 @@ public class ExtractionTestGenerated extends AbstractExtractionTest {
|
||||
doIntroduceSimpleParameterTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("inDefaultValue.kt")
|
||||
public void testInDefaultValue() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/inDefaultValue.kt");
|
||||
doIntroduceSimpleParameterTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("lambdaArgument.kt")
|
||||
public void testLambdaArgument() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/refactoring/introduceParameter/lambdaArgument.kt");
|
||||
|
||||
Reference in New Issue
Block a user