diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java index f5efc39c48ec..46b9d4f79ee4 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyIndentProcessor.java @@ -36,6 +36,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.auxiliary.GrThrowsClause; import org.jetbrains.plugins.groovy.lang.psi.api.formatter.GrControlStatement; import org.jetbrains.plugins.groovy.lang.psi.api.statements.*; import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrArgumentList; +import org.jetbrains.plugins.groovy.lang.psi.api.statements.arguments.GrNamedArgument; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrAssignmentExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrConditionalExpression; import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrElvisExpression; @@ -138,6 +139,10 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes { return Indent.getSpaceIndent(GDOC_COMMENT_INDENT); } + if (psiParent instanceof GrNamedArgument) { + return Indent.getContinuationIndent(); + } + if (child.getPsi() instanceof GrVariable && psiParent instanceof GrVariableDeclaration) { return Indent.getContinuationWithoutFirstIndent(); } diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java index eadba563a12d..a10b29c60fe1 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.java @@ -151,6 +151,7 @@ public class FormatterTest extends GroovyFormatterTestCase { public void testPreserveChainingLineBreaks() throws Throwable { doTest(); } public void testMultilineEolComment() throws Throwable { doTest(); } public void testRedundantClosureSpace() throws Throwable { doTest(); } + public void testIndentNamedArguments() throws Throwable { doTest(); } public void testAlignChainedCalls() throws Throwable { getGroovySettings().ALIGN_MULTILINE_CHAINED_METHODS = true; diff --git a/plugins/groovy/testdata/groovy/formatter/indentNamedArguments.test b/plugins/groovy/testdata/groovy/formatter/indentNamedArguments.test new file mode 100644 index 000000000000..f821be8f63db --- /dev/null +++ b/plugins/groovy/testdata/groovy/formatter/indentNamedArguments.test @@ -0,0 +1,15 @@ +def foo() { + Object o = new Object(lut: + ([] + + (0..9). + collect { it }).collect { [it.foo, it.bar] }, minSimilarity: 0.91f + ) +} +----- +def foo() { + Object o = new Object(lut: + ([] + + (0..9). + collect { it }).collect { [it.foo, it.bar] }, minSimilarity: 0.91f + ) +} \ No newline at end of file