IDEA-61395 Groovy: incorrect anonymous classes formatting

This commit is contained in:
peter
2011-04-08 20:19:10 +02:00
parent 324a9127a6
commit 4dce69198e
3 changed files with 18 additions and 1 deletions
@@ -42,6 +42,7 @@ import org.jetbrains.plugins.groovy.lang.psi.api.statements.blocks.GrCodeBlock;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrBinaryExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.expressions.GrConditionalExpression;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.params.GrParameterList;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrAnonymousClassDefinition;
import org.jetbrains.plugins.groovy.lang.psi.api.statements.typedef.GrExtendsClause;
import java.util.ArrayList;
@@ -152,7 +153,7 @@ public class GroovyBlockGenerator implements GroovyElementTypes {
ASTNode prevChildNode = null;
for (ASTNode childNode : visibleChildren(node)) {
final Indent indent = GroovyIndentProcessor.getChildIndent(block, prevChildNode, childNode);
subBlocks.add(new GroovyBlock(childNode, myAlignment, indent, myWrap, mySettings, block.myInnerAlignments));
subBlocks.add(new GroovyBlock(childNode, blockPsi instanceof GrAnonymousClassDefinition ? null : myAlignment, indent, myWrap, mySettings, block.myInnerAlignments));
prevChildNode = childNode;
}
return subBlocks;
@@ -129,6 +129,11 @@ public class FormatterTest extends GroovyFormatterTestCase {
}
public void testCaseInSwitchIndented() throws Throwable { doTest(); }
public void testAnonymousInCall() throws Throwable {
myTempSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
doTest();
}
public void testClosureParametersAligned() throws Throwable {
myTempSettings.ALIGN_MULTILINE_PARAMETERS_IN_CALLS = true;
doTest();
@@ -0,0 +1,11 @@
bar(new Runnable() {
void run() {
}
})
-----
bar(new Runnable() {
void run() {
}
})