class SyntaxTree::Statements
def format(q)
def format(q) line = nil # This handles a special case where you've got a block of statements where # the only value is a comment. In that case a lot of nodes like # brace_block will attempt to format as a single line, but since that # wouldn't work with a comment, we intentionally break the parent group. if body.length == 2 void_stmt, comment = body if void_stmt.is_a?(VoidStmt) && comment.is_a?(Comment) q.format(comment) q.break_parent return end end previous = nil body.each do |statement| next if statement.is_a?(VoidStmt) if line.nil? q.format(statement) elsif (statement.location.start_line - line) > 1 q.breakable_force q.breakable_force q.format(statement) elsif (statement.is_a?(VCall) && statement.access_control?) || (previous.is_a?(VCall) && previous.access_control?) q.breakable_force q.breakable_force q.format(statement) elsif statement.location.start_line != line q.breakable_force q.format(statement) elsif !q.parent.is_a?(StringEmbExpr) q.breakable_force q.format(statement) else q.text("; ") q.format(statement) end line = statement.location.end_line previous = statement end end