ArrayLiteral
represents an array literal, which can optionally contain elements.
[] [one, two, three]Constants
Args
the contents of the array
def initialize(lbracket:, contents:, location:) @lbracket = lbracket @contents = contents @location = location @comments = [] endPublic Instance Methods Source
def ===(other) other.is_a?(ArrayLiteral) && lbracket === other.lbracket && contents === other.contents endSource
def accept(visitor) visitor.visit_array(self) endSource
def child_nodes [lbracket, contents] endSource
def copy(lbracket: nil, contents: nil, location: nil) node = ArrayLiteral.new( lbracket: lbracket || self.lbracket, contents: contents || self.contents, location: location || self.location ) node.comments.concat(comments.map(&:copy)) node endSource
def deconstruct_keys(_keys) { lbracket: lbracket, contents: contents, location: location, comments: comments } endSource
def format(q) lbracket = self.lbracket contents = self.contents if lbracket.is_a?(LBracket) && lbracket.comments.empty? && contents && contents.comments.empty? && contents.parts.length > 1 if qwords? QWordsFormatter.new(contents).format(q) return end if qsymbols? QSymbolsFormatter.new(contents).format(q) return end end if empty_with_comments? EmptyWithCommentsFormatter.new(lbracket).format(q) return end q.group do q.format(lbracket) if contents 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("]") end end
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4