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 46b9d4f79ee4..835a2e30884b 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 @@ -113,6 +113,9 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes { if (psiParent instanceof GrExpression) { return getExpressionIndent(psiParent, child); } + if (psiParent instanceof GrVariable && child.getPsi() == ((GrVariable)psiParent).getInitializerGroovy()) { + return Indent.getNormalIndent(); + } //For parameter lists if (psiParent instanceof GrParameterList || @@ -139,7 +142,7 @@ public abstract class GroovyIndentProcessor implements GroovyElementTypes { return Indent.getSpaceIndent(GDOC_COMMENT_INDENT); } - if (psiParent instanceof GrNamedArgument) { + if (psiParent instanceof GrNamedArgument && child.getPsi() == ((GrNamedArgument)psiParent).getExpression()) { return Indent.getContinuationIndent(); } 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 a10b29c60fe1..4b2fec012b1f 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 @@ -152,6 +152,7 @@ public class FormatterTest extends GroovyFormatterTestCase { public void testMultilineEolComment() throws Throwable { doTest(); } public void testRedundantClosureSpace() throws Throwable { doTest(); } public void testIndentNamedArguments() throws Throwable { doTest(); } + public void testIndentAssigned() throws Throwable { doTest(); } public void testAlignChainedCalls() throws Throwable { getGroovySettings().ALIGN_MULTILINE_CHAINED_METHODS = true; diff --git a/plugins/groovy/testdata/groovy/formatter/indentAssigned.test b/plugins/groovy/testdata/groovy/formatter/indentAssigned.test new file mode 100644 index 000000000000..e6ac51e31c2e --- /dev/null +++ b/plugins/groovy/testdata/groovy/formatter/indentAssigned.test @@ -0,0 +1,19 @@ +def playerStatuses = +setup.regions[ts].collect { + + } + + playerStatuses = + setup.regions[ts].collect { + + } +----- +def playerStatuses = + setup.regions[ts].collect { + + } + +playerStatuses = + setup.regions[ts].collect { + + } \ No newline at end of file