visitIfStmt method

  1. @override
GzBaseNode visitIfStmt(
  1. IfStmt stmt
)
override

Implementation

@override
GzBaseNode visitIfStmt(IfStmt stmt) {
  final body = stmt.body.map((e) => e.accept(this)).toList();

  if (stmt.isTerminalElse) {
    return node('stmts', color: pink, children: body);
  }

  return node(
    'if',
    shape: 'diamond',
    color: 'yellow',
    children: [
      node('expr', color: pink, children: [stmt.expr!.accept(this)]),
      node('stmts', color: pink, children: body),
      if (stmt.nextIfStmt != null)
        node('else', color: muave, children: [stmt.nextIfStmt!.accept(this)]),
    ],
  );
}