From 27fca99c771e10f28eb897e5be0b60756c317089 Mon Sep 17 00:00:00 2001 From: "Maxim.Medvedev" Date: Tue, 29 May 2012 16:47:47 +0400 Subject: [PATCH] \n in enforced braces --- .../plugins/groovy/formatter/GroovyBraceEnforcer.java | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBraceEnforcer.java b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBraceEnforcer.java index 371c27c025c6..d166f44a64d6 100644 --- a/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBraceEnforcer.java +++ b/plugins/groovy/src/org/jetbrains/plugins/groovy/formatter/GroovyBraceEnforcer.java @@ -77,15 +77,9 @@ public class GroovyBraceEnforcer extends GroovyRecursiveElementVisitor { // if (true) i = 1; // Cool assignment // We can't just surround target block of code with curly braces because the closing one will be treated as comment as well. // Hence, we perform a check if we have such situation at the moment and insert new line before the closing brace. - int lastLineFeedIndex = oldText.lastIndexOf("\n"); - lastLineFeedIndex = Math.max(0, lastLineFeedIndex); - int lastLineCommentIndex = oldText.indexOf("//", lastLineFeedIndex); StringBuilder buf = new StringBuilder(oldText.length() + 5); - buf.append("{ ").append(oldText); - if (lastLineCommentIndex >= 0) { - buf.append("\n"); - } - buf.append(" }"); + buf.append("{\n").append(oldText); + buf.append("\n}"); final int oldTextLength = statement.getTextLength(); try { CodeEditUtil.replaceChild(SourceTreeToPsiMap.psiElementToTree(statement),