class SyntaxTree::Kw
then the contents of the symbol node will contain a Kw node.
:if
will use a Kw, so if you use a keyword in a symbol literal for instance:
for the end. Note that anything that matches the list of keywords in Ruby
In the above example, there would be two Kw nodes: one for the if and one
end
if value
tree, so you end up seeing it quite a lot.
Kw represents the use of a keyword. It can be almost anywhere in the syntax
def ===(other)
def ===(other) other.is_a?(Kw) && value === other.value end
def accept(visitor)
def accept(visitor) visitor.visit_kw(self) end
def child_nodes
def child_nodes [] end
def copy(value: nil, location: nil)
def copy(value: nil, location: nil) node = Kw.new(value: value || self.value, location: location || self.location) node.comments.concat(comments.map(&:copy)) node end
def deconstruct_keys(_keys)
def deconstruct_keys(_keys) { value: value, location: location, comments: comments } end
def format(q)
def format(q) q.text(value) end
def initialize(value:, location:)
def initialize(value:, location:) @value = value @name = value.to_sym @location = location @comments = [] end