diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java index 1d4f63264bb9..d7ba4e872c68 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBlockGenerator.java @@ -100,6 +100,19 @@ public class GroovyBlockGenerator implements GroovyElementTypes { } + //for gstrings + if (block.getNode().getElementType() == GSTRING) { + final ArrayList subBlocks = new ArrayList(); + ASTNode children[] = getGroovyChildren(node); + ASTNode prevChildNode = null; + for (ASTNode childNode : children) { + final Indent indent = GroovyIndentProcessor.getChildIndent(block, prevChildNode, childNode); + subBlocks.add(new GroovyBlock(childNode, myAlignment, indent, myWrap, mySettings)); + prevChildNode = childNode; + } + return subBlocks; + } + //For nested selections if (NESTED.contains(block.getNode().getElementType()) && blockPsi.getParent() != null && 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 93a5284e21ef..f32966e7fc0b 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 @@ -65,6 +65,7 @@ public class FormatterTest extends GroovyFormatterTestCase { public void testFor2() throws Throwable { doTest(); } public void testGbegin1() throws Throwable { doTest(); } public void testGrvy1637() throws Throwable { doTest(); } + public void testGString1() throws Throwable { doTest(); } public void testMap6() throws Throwable { doTest(); } public void testMeth1() throws Throwable { doTest(); } public void testMeth2() throws Throwable { doTest(); } diff --git a/plugins/groovy/testdata/groovy/formatter/GString1.test b/plugins/groovy/testdata/groovy/formatter/GString1.test new file mode 100644 index 000000000000..67f5c16c5d99 --- /dev/null +++ b/plugins/groovy/testdata/groovy/formatter/GString1.test @@ -0,0 +1,3 @@ +def a = "${1+2} ${2}" +----- +def a = "${1 + 2} ${2}" \ No newline at end of file