class Prism::SingletonClassNode

表示涉及 ‘class` 关键字的单例类声明。

class << self end
^^^^^^^^^^^^^^^^^

属性

body[R]

attr_reader body: StatementsNode | BeginNode | nil

expression[R]

attr_reader expression: Prism::node

locals[R]

attr_reader locals: Array

公共类方法

new(source, node_id, location, flags, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc) 点击切换源代码

初始化一个新的 SingletonClassNode 节点。

# File prism/node.rb, line 16294
def initialize(source, node_id, location, flags, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc)
  @source = source
  @node_id = node_id
  @location = location
  @flags = flags
  @locals = locals
  @class_keyword_loc = class_keyword_loc
  @operator_loc = operator_loc
  @expression = expression
  @body = body
  @end_keyword_loc = end_keyword_loc
end
type() 点击切换源代码

返回此节点类型的符号表示。请参阅 ‘Node::type`。

# File prism/node.rb, line 16417
def self.type
  :singleton_class_node
end

公共实例方法

===(other) 点击切换源代码

实现节点的 case-equality。这实际上是 ==,但不比较位置的值。仅检查位置是否存在。

# File prism/node.rb, line 16423
def ===(other)
  other.is_a?(SingletonClassNode) &&
    (locals.length == other.locals.length) &&
    locals.zip(other.locals).all? { |left, right| left === right } &&
    (class_keyword_loc.nil? == other.class_keyword_loc.nil?) &&
    (operator_loc.nil? == other.operator_loc.nil?) &&
    (expression === other.expression) &&
    (body === other.body) &&
    (end_keyword_loc.nil? == other.end_keyword_loc.nil?)
end
accept(visitor) 点击切换源代码

def accept: (Visitor visitor) -> void

# File prism/node.rb, line 16308
def accept(visitor)
  visitor.visit_singleton_class_node(self)
end
child_nodes() 点击切换源代码

def child_nodes: () -> Array[nil | Node]

# File prism/node.rb, line 16313
def child_nodes
  [expression, body]
end
也别名为:deconstruct
class_keyword() 点击切换源代码

def class_keyword: () -> String

# File prism/node.rb, line 16392
def class_keyword
  class_keyword_loc.slice
end
class_keyword_loc() 点击切换源代码

attr_reader class_keyword_loc: Location

# File prism/node.rb, line 16347
def class_keyword_loc
  location = @class_keyword_loc
  return location if location.is_a?(Location)
  @class_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end
comment_targets() 点击切换源代码

def comment_targets: () -> Array[Node | Location]

# File prism/node.rb, line 16326
def comment_targets
  [class_keyword_loc, operator_loc, expression, *body, end_keyword_loc] #: Array[Prism::node | Location]
end
compact_child_nodes() 点击切换源代码

def compact_child_nodes: () -> Array

# File prism/node.rb, line 16318
def compact_child_nodes
  compact = [] #: Array[Prism::node]
  compact << expression
  compact << body if body
  compact
end
copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, class_keyword_loc: self.class_keyword_loc, operator_loc: self.operator_loc, expression: self.expression, body: self.body, end_keyword_loc: self.end_keyword_loc) 点击切换源代码

def copy: (?node_id: Integer, ?location: Location, ?flags: Integer, ?locals: Array, ?class_keyword_loc: Location, ?operator_loc: Location, ?expression: Prism::node, ?body: StatementsNode | BeginNode | nil, ?end_keyword_loc: Location) -> SingletonClassNode

# File prism/node.rb, line 16331
def copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, class_keyword_loc: self.class_keyword_loc, operator_loc: self.operator_loc, expression: self.expression, body: self.body, end_keyword_loc: self.end_keyword_loc)
  SingletonClassNode.new(source, node_id, location, flags, locals, class_keyword_loc, operator_loc, expression, body, end_keyword_loc)
end
deconstruct()

def deconstruct: () -> Array[nil | Node]

别名:child_nodes
deconstruct_keys(keys) 点击切换源代码

def deconstruct_keys: (Array keys) -> { node_id: Integer, location: Location, locals: Array, class_keyword_loc: Location, operator_loc: Location, expression: Prism::node, body: StatementsNode | BeginNode | nil, end_keyword_loc: Location }

# File prism/node.rb, line 16339
def deconstruct_keys(keys)
  { node_id: node_id, location: location, locals: locals, class_keyword_loc: class_keyword_loc, operator_loc: operator_loc, expression: expression, body: body, end_keyword_loc: end_keyword_loc }
end
end_keyword() 点击切换源代码

def end_keyword: () -> String

# File prism/node.rb, line 16402
def end_keyword
  end_keyword_loc.slice
end
end_keyword_loc() 点击切换源代码

attr_reader end_keyword_loc: Location

# File prism/node.rb, line 16379
def end_keyword_loc
  location = @end_keyword_loc
  return location if location.is_a?(Location)
  @end_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end
inspect() 点击切换源代码

def inspect -> String

# File prism/node.rb, line 16407
def inspect
  InspectVisitor.compose(self)
end
operator() 点击切换源代码

def operator: () -> String

# File prism/node.rb, line 16397
def operator
  operator_loc.slice
end
operator_loc() 点击切换源代码

attr_reader operator_loc: Location

# File prism/node.rb, line 16360
def operator_loc
  location = @operator_loc
  return location if location.is_a?(Location)
  @operator_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF)
end
save_class_keyword_loc(repository) 点击切换源代码

使用给定的已保存源保存 class_keyword_loc 位置,以便稍后检索。

# File prism/node.rb, line 16355
def save_class_keyword_loc(repository)
  repository.enter(node_id, :class_keyword_loc)
end
save_end_keyword_loc(repository) 点击切换源代码

使用给定的已保存源保存 end_keyword_loc 位置,以便稍后检索。

# File prism/node.rb, line 16387
def save_end_keyword_loc(repository)
  repository.enter(node_id, :end_keyword_loc)
end
save_operator_loc(repository) 点击切换源代码

使用给定的已保存源保存 operator_loc 位置,以便稍后检索。

# File prism/node.rb, line 16368
def save_operator_loc(repository)
  repository.enter(node_id, :operator_loc)
end
type() 点击切换源代码

返回此节点类型的符号表示。请参阅 ‘Node#type`。

# File prism/node.rb, line 16412
def type
  :singleton_class_node
end