mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
\n in enforced braces
This commit is contained in:
@@ -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),
|
||||
|
||||
Reference in New Issue
Block a user