visitIfStmt method

  1. @override
void visitIfStmt(
  1. IfStmt stmt,
  2. EmitterVisitorContext context
)
override

Implementation

@override
void visitIfStmt(o.IfStmt stmt, EmitterVisitorContext context) {
  context.print('if (');
  stmt.condition.visitExpression(this, context);
  context.print(') {');
  var hasElseCase = stmt.falseCase.isNotEmpty;
  if (stmt.trueCase.length <= 1 && !hasElseCase) {
    context.print(' ');
    visitAllStatements(stmt.trueCase, context);
    context.removeEmptyLastLine();
    context.print(' ');
  } else {
    context.println();
    context.incIndent();
    visitAllStatements(stmt.trueCase, context);
    context.decIndent();
    if (hasElseCase) {
      context.println('} else {');
      context.incIndent();
      visitAllStatements(stmt.falseCase, context);
      context.decIndent();
    }
  }
  context.println('}');
}