13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/johnson/ext.rb', line 13
def visit_SourceElements(o)
newline = o.value.length > 0 ? "\n" : ' '
(@depth == 0 ? '' : "{#{newline}") +
indent {
o.value.map { |x|
code = x.accept(self)
semi = case x
when Nodes::FallThrough
""
when Nodes::Function, Nodes::While, Nodes::If, Nodes::Try, Nodes::Switch, Nodes::Case, Nodes::Default, Nodes::For, Nodes::ForIn
code =~ /\}\Z/ ? '' : ';'
else
';'
end
"#{indent}#{code}#{semi}"
}.join("\n")
} +
(@depth == 0 ? '' : "#{newline}}")
end
|