From 4cd7b8a0ecae5b80ebf772fbff21e42d9dbb8087 Mon Sep 17 00:00:00 2001 From: Max Medvedev Date: Wed, 19 Mar 2014 12:47:24 +0400 Subject: [PATCH] IDEA-122398 all wraps inside plain GString injections should be NONE --- .../groovy/formatter/processors/GroovyWrappingProcessor.java | 5 +++-- .../plugins/groovy/lang/formatter/FormatterTest.groovy | 2 ++ .../testdata/groovy/formatter/noLineFeedsInGString.test | 3 +++ 3 files changed, 8 insertions(+), 2 deletions(-) create mode 100644 plugins/groovy/testdata/groovy/formatter/noLineFeedsInGString.test diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java index 67281f093d4b..704a652b60df 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/processors/GroovyWrappingProcessor.java @@ -1,5 +1,5 @@ /* - * Copyright 2000-2013 JetBrains s.r.o. + * Copyright 2000-2014 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -237,7 +237,8 @@ public class GroovyWrappingProcessor { } public Wrap getChainedMethodCallWrap() { - return Wrap.createWrap(mySettings.METHOD_CALL_CHAIN_WRAP, false); + return myContext.isInsidePlainGString() ? Wrap.createWrap(WrapType.NONE, false) + : Wrap.createWrap(mySettings.METHOD_CALL_CHAIN_WRAP, false); } private TokenSet ANNOTATION_CONTAINERS = TokenSet.create( diff --git a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy index 01cb0f735a43..bea7f0742361 100644 --- a/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy +++ b/plugins/groovy/test/org/jetbrains/plugins/groovy/lang/formatter/FormatterTest.groovy @@ -798,6 +798,8 @@ def foo() { } } + void testNoLineFeedsInGString() { doTest() } + private void doGeeseTest() { GroovyCodeStyleSettings customSettings = myTempSettings.getCustomSettings(GroovyCodeStyleSettings.class) boolean oldvalue = customSettings.USE_FLYING_GEESE_BRACES diff --git a/plugins/groovy/testdata/groovy/formatter/noLineFeedsInGString.test b/plugins/groovy/testdata/groovy/formatter/noLineFeedsInGString.test new file mode 100644 index 000000000000..d01b36fdeb88 --- /dev/null +++ b/plugins/groovy/testdata/groovy/formatter/noLineFeedsInGString.test @@ -0,0 +1,3 @@ +print " {left(email.user?.raw, (length / 2).toInteger())}@${left(email.domain?.raw, (length - length / 2 - 1).toInteger())}" +----- +print " {left(email.user?.raw, (length / 2).toInteger())}@${left(email.domain?.raw, (length - length / 2 - 1).toInteger())}"