named argument values should be continuation-indented from their names (IDEA-73865)

This commit is contained in:
peter
2011-10-06 19:49:12 +02:00
parent 556bc6f123
commit 6e46d81c21
3 changed files with 21 additions and 0 deletions
@@ -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();
}
@@ -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;
@@ -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
)
}