[kotlin] Indent named arguments with normal or continuation indent

^KTIJ-30843 fixed


Merge-request: IJ-MR-141664
Merged-by: Frederik Haselmeier <Frederik.Haselmeier@jetbrains.com>

GitOrigin-RevId: 9e06ee7f97bf6e714f74ca73ecbe49558b8e4c37
This commit is contained in:
Frederik Haselmeier
2024-08-06 15:25:13 +00:00
committed by intellij-monorepo-bot
parent e4c058bd2b
commit a3f19a1125
11 changed files with 100 additions and 0 deletions

View File

@@ -1101,6 +1101,15 @@ private val INDENT_RULES = arrayOf(
.within(VALUE_PARAMETER)
.forElement { node -> node.psi != null && node.psi == (node.psi.parent as? KtParameter)?.defaultValue }
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES, indentFirst = true),
strategy("Named arguments")
.within(VALUE_ARGUMENT)
.notForType(EQ, VALUE_ARGUMENT_NAME)
.forElement { node ->
val parent = node.psi?.parent
parent is KtValueArgument && parent.isNamed()
}
.continuationIf(KotlinCodeStyleSettings::CONTINUATION_INDENT_FOR_EXPRESSION_BODIES, indentFirst = true),
)

View File

@@ -297,6 +297,21 @@ public abstract class FormatterTestGenerated extends AbstractFormatterTest {
runTest("testData/formatter/parameterList/ArgumentListDoNotWrap.after.kt");
}
@TestMetadata("ArgumentListNamedArguments.after.kt")
public void testArgumentListNamedArguments() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListNamedArguments.after.kt");
}
@TestMetadata("ArgumentListNamedArgumentsFunctionCall.after.kt")
public void testArgumentListNamedArgumentsFunctionCall() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListNamedArgumentsFunctionCall.after.kt");
}
@TestMetadata("ArgumentListNamedArgumentsInFunction.after.kt")
public void testArgumentListNamedArgumentsInFunction() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListNamedArgumentsInFunction.after.kt");
}
@TestMetadata("ArgumentListWrapAlways.after.kt")
public void testArgumentListWrapAlways() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListWrapAlways.after.kt");
@@ -1714,6 +1729,21 @@ public abstract class FormatterTestGenerated extends AbstractFormatterTest {
KotlinTestUtils.runTest(this::doTestInverted, this, testDataFilePath);
}
@TestMetadata("ArgumentListNamedArguments.after.inv.kt")
public void testArgumentListNamedArguments() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListNamedArguments.after.inv.kt");
}
@TestMetadata("ArgumentListNamedArgumentsFunctionCall.after.inv.kt")
public void testArgumentListNamedArgumentsFunctionCall() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListNamedArgumentsFunctionCall.after.inv.kt");
}
@TestMetadata("ArgumentListNamedArgumentsInFunction.after.inv.kt")
public void testArgumentListNamedArgumentsInFunction() throws Exception {
runTest("testData/formatter/parameterList/ArgumentListNamedArgumentsInFunction.after.inv.kt");
}
@TestMetadata("DefaultParameterValues.after.inv.kt")
public void testDefaultParameterValues() throws Exception {
runTest("testData/formatter/parameterList/DefaultParameterValues.after.inv.kt");

View File

@@ -0,0 +1,5 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val a = test(
a =
""
)

View File

@@ -0,0 +1,5 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val a = test(
a =
""
)

View File

@@ -0,0 +1,5 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val a = test(
a =
""
)

View File

@@ -0,0 +1,7 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val a = test(
a =
listOf(
1
)
)

View File

@@ -0,0 +1,7 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val a = test(
a =
listOf(
1
)
)

View File

@@ -0,0 +1,7 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
val a = test(
a =
listOf(
1
)
)

View File

@@ -0,0 +1,9 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun foo() {
return bar(
test1 = 1,
test2 =
"Some VERY Long string",
test3 = 1
)
}

View File

@@ -0,0 +1,9 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun foo() {
return bar(
test1 = 1,
test2 =
"Some VERY Long string",
test3 = 1
)
}

View File

@@ -0,0 +1,7 @@
// SET_TRUE: CONTINUATION_INDENT_FOR_EXPRESSION_BODIES
fun foo() {
return bar(test1 = 1,
test2 =
"Some VERY Long string",
test3 = 1)
}