# Is the node inlinable and can fit on the line.
fun can_inline(n: nullable ANode): Bool do
if n == null then return true
+ if no_inline and n.location.line_start != n.location.line_end then return false
if n.must_be_inline then return true
if n.must_be_block then return false
# check length
# Do we force the deletion of empty lines?
var skip_empty = false is public writable
+
+ # Disable automatic inlining.
+ var no_inline = false is writable
end
# Base framework redefs
v.adds
v.visit_list n_extern_calls
else
- v.addn
+ v.forcen
v.indent += 1
v.addt
v.indent -= 1
v.add "`\{"
if not lines.first.trim.is_empty then
- v.addn
+ v.forcen
lines.first.l_trim
v.indent += 1
v.addt
v.adds
else
v.visit n_expr
- v.addn
+ v.forcen
v.addt
end
v.visit_recv n_expr
if not n_expr isa AImplicitSelfExpr and not can_inline then
- v.addn
+ v.forcen
v.addt
end
- v.visit n_id
+ v.visit n_qid
if not n_args.n_exprs.is_empty then
if is_stmt and n_args.n_exprs.length == 1 then
redef class ACallAssignExpr
redef fun accept_pretty_printer(v) do
v.visit_recv n_expr
- v.visit n_id
+ v.visit n_qid
if not n_args.n_exprs.is_empty then
v.consume "("
redef class ACallReassignExpr
redef fun accept_pretty_printer(v) do
v.visit_recv n_expr
- v.visit n_id
+ v.visit n_qid
if not n_args.n_exprs.is_empty then
v.consume "("
v.adds
v.visit n_type
- if n_id != null then
+ if n_qid != null then
v.consume "."
if not can_inline then
- v.addn
+ v.forcen
v.indent += 1
v.addt
v.indent -= 1
end
- v.visit n_id
+ v.visit n_qid
end
v.visit_args n_args.n_exprs
else
v.addt
v.visit n_else
- v.addn
+ v.forcen
v.indent -= 1
v.addt
v.add "end"
v.adds
v.visit bin_expr2
else
- v.addn
+ v.forcen
v.indent += 1
v.addt
v.indent -= 1
# Syntax
-redef class AUplusExpr
- redef fun accept_pretty_printer(v) do
- v.consume "+"
- v.visit n_expr
- end
-end
-
-redef class AUminusExpr
+redef class AUnaryopExpr
redef fun accept_pretty_printer(v) do
- v.consume "-"
+ v.visit n_op
v.visit n_expr
end
end