34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
# File 'lib/syntax_tree/node.rb', line 34
def format(q)
opening, closing = "[", "]"
q.group do
q.text(opening)
unless elements.empty?
loc = elements.first.location.to(elements.last.location)
str_contents =
elements.map do |element|
StringContent.new(parts: [element], location: nil)
end
contents = Args.new(parts: str_contents, location: loc)
q.indent do
q.breakable_empty
q.format(contents)
q.if_break { q.text(",") } if q.trailing_comma?
end
end
q.breakable_empty
q.text(closing)
end
end
|