TextBuffer (int indent, @NotNull BytecodeMappingTracer tracer) { SwitchHelper.simplifySwitchOnEnum(this); TextBuffer buf = new TextBuffer(); buf.append(ExprProcessor.listToJava(varDefinitions, indent, tracer)); buf.append(first.toJava(indent, tracer)); if (isLabeled()) { buf.appendIndent(indent).append("label").append(Integer.toString(id)).append(":").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } buf.appendIndent(indent).append(headExprent.toJava(indent, tracer)).append(" {").appendLineSeparator(); tracer.incrementCurrentSourceLine(); VarType switchType = headExprent.getExprType(); for (int i = 0; i < caseStatements.size(); i++) { Statement stat = caseStatements.get(i); List<StatEdge> edges = caseEdges.get(i); List<Exprent> values = caseValues.get(i); for (int j = 0; j < edges.size(); j++) { if (edges.get(j) == defaultEdge) { if (!canBeRule) { buf.appendIndent(indent + 1).append("default:").appendLineSeparator(); } else { buf.appendIndent(indent + 1).append("default -> "); } } else { buf.appendIndent(indent + 1).append("case "); Exprent value = values.get(j); if (value instanceof ConstExprent constExprent && !constExprent.isNull()) { value = value.copy(); if (switchType.getType() != TYPE_OBJECT) { ((ConstExprent)value).setConstType(switchType); } else if (((JAVA_LANG_CHARACTER).equals(switchType.getValue()))) { ((ConstExprent)value).setConstType(VARTYPE_CHAR); } } if (value instanceof FieldExprent && ((FieldExprent)value).isStatic()) { // enum values buf.append(((FieldExprent)value).getName()); } else { buf.append(value.toJava(indent, tracer)); } Exprent guard = guards.get(stat); if (guard != null) { buf.append(" when ").append(guard.toJava(0, tracer)); } if (!canBeRule) { buf.append(":").appendLineSeparator(); } else { buf.append(" -> "); } } if (!canBeRule) { tracer.incrementCurrentSourceLine(); } } //example: //case 0: break if (canBeRule && stat instanceof BasicBlockStatement blockStatement && blockStatement.getBlock().getSeq().isEmpty() && (stat.getExprents() == null || stat.getExprents().isEmpty())) { buf.append("{ }").appendLineSeparator(); tracer.incrementCurrentSourceLine(); } else { buf.append(ExprProcessor.jmpWrapper(stat, canBeRule ? 0 : indent + 2, false, tracer)); } } buf.appendIndent(indent).append("}").appendLineSeparator(); tracer.incrementCurrentSourceLine(); return buf; }