New braces style

git-svn-id: https://svn.code.sf.net/p/jode/code/trunk@206 379699f6-c40d-0410-875b-85095c16579e
stable
jochen 26 years ago
parent acfe14f7af
commit c68e14fc05
  1. 19
      jode/jode/flow/IfThenElseBlock.java

@ -97,13 +97,18 @@ public class IfThenElseBlock extends StructuredBlock {
throws java.io.IOException throws java.io.IOException
{ {
boolean needBrace = thenBlock.needsBraces(); boolean needBrace = thenBlock.needsBraces();
writer.println("if ("+cond.simplify().toString()+")" writer.print("if ("+cond.simplify().toString()+")");
+(needBrace?" {":"")); if (needBrace)
writer.openBrace();
else
writer.println();
writer.tab(); writer.tab();
thenBlock.dumpSource(writer); thenBlock.dumpSource(writer);
writer.untab(); writer.untab();
if (elseBlock != null) { if (elseBlock != null) {
writer.print(needBrace ? "} " : ""); if (needBrace)
writer.closeBraceContinue();
if (elseBlock instanceof IfThenElseBlock if (elseBlock instanceof IfThenElseBlock
&& (elseBlock.declare == null && (elseBlock.declare == null
|| elseBlock.declare.isEmpty())) { || elseBlock.declare.isEmpty())) {
@ -112,14 +117,18 @@ public class IfThenElseBlock extends StructuredBlock {
elseBlock.dumpSource(writer); elseBlock.dumpSource(writer);
} else { } else {
needBrace = elseBlock.needsBraces(); needBrace = elseBlock.needsBraces();
writer.println("else" + (needBrace ? " {" : "")); writer.print("else");
if (needBrace)
writer.openBrace();
else
writer.println();
writer.tab(); writer.tab();
elseBlock.dumpSource(writer); elseBlock.dumpSource(writer);
writer.untab(); writer.untab();
} }
} }
if (needBrace) if (needBrace)
writer.println("}"); writer.closeBrace();
} }
/** /**

Loading…
Cancel
Save