Skip to content

Commit

Permalink
Must implement showCode
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Feb 4, 2025
1 parent 40edc67 commit fbdd31c
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,4 +49,16 @@ public IfThenElse copy(Expression cond, Expression trueBranch, Expression falseB
public scala.Option<Expression> falseBranch() {
return scala.Option.apply(falseBranchOrNull());
}

@Override
public String showCode(int indent) {
var newIndent = indent + indentLevel;
var headerStr = "if " + cond().showCode(0) + " then\n" + trueBranch().showCode(newIndent);
var elseStr =
switch (falseBranchOrNull()) {
case Expression f -> " ".repeat(indent) + "else\n" + f.showCode(newIndent);
case null -> "";
};
return headerStr + "\n" + elseStr;
}
}

0 comments on commit fbdd31c

Please sign in to comment.