class Prism::ModuleNode
表示涉及 `module` 关键字的模块声明。
module Foo end ^^^^^^^^^^^^^^
属性
attr_reader body: StatementsNode
| BeginNode
| nil
attr_reader constant_path
: ConstantReadNode
| ConstantPathNode
| MissingNode
attr_reader locals: Array
attr_reader name: Symbol
公共类方法
初始化一个新的 ModuleNode
节点。
# File prism/node.rb, line 12880 def initialize(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name) @source = source @node_id = node_id @location = location @flags = flags @locals = locals @module_keyword_loc = module_keyword_loc @constant_path = constant_path @body = body @end_keyword_loc = end_keyword_loc @name = name end
返回此节点类型的符号表示。请参阅 'Node::type'。
# File prism/node.rb, line 12988 def self.type :module_node end
公共实例方法
为节点实现 case-equality。这实际上是 ==,但不比较位置的值。仅检查位置是否存在。
# File prism/node.rb, line 12994 def ===(other) other.is_a?(ModuleNode) && (locals.length == other.locals.length) && locals.zip(other.locals).all? { |left, right| left === right } && (module_keyword_loc.nil? == other.module_keyword_loc.nil?) && (constant_path === other.constant_path) && (body === other.body) && (end_keyword_loc.nil? == other.end_keyword_loc.nil?) && (name === other.name) end
def accept: (Visitor
visitor) -> void
# File prism/node.rb, line 12894 def accept(visitor) visitor.visit_module_node(self) end
def child_nodes
: () -> Array[nil | Node]
# File prism/node.rb, line 12899 def child_nodes [constant_path, body] end
def comment_targets
: () -> Array[Node | Location]
# File prism/node.rb, line 12912 def comment_targets [module_keyword_loc, constant_path, *body, end_keyword_loc] #: Array[Prism::node | Location] end
def compact_child_nodes
: () -> Array
# File prism/node.rb, line 12904 def compact_child_nodes compact = [] #: Array[Prism::node] compact << constant_path compact << body if body compact end
def copy: (?node_id: Integer, ?location: Location
, ?flags: Integer, ?locals: Array, ?module_keyword_loc: Location
, ?constant_path: ConstantReadNode
| ConstantPathNode
| MissingNode
, ?body: StatementsNode
| BeginNode
| nil, ?end_keyword_loc: Location
, ?name: Symbol) -> ModuleNode
# File prism/node.rb, line 12917 def copy(node_id: self.node_id, location: self.location, flags: self.flags, locals: self.locals, module_keyword_loc: self.module_keyword_loc, constant_path: self.constant_path, body: self.body, end_keyword_loc: self.end_keyword_loc, name: self.name) ModuleNode.new(source, node_id, location, flags, locals, module_keyword_loc, constant_path, body, end_keyword_loc, name) end
def deconstruct_keys
: (Array keys) -> { node_id: Integer, location: Location
, locals: Array, module_keyword_loc
: Location
, constant_path
: ConstantReadNode
| ConstantPathNode
| MissingNode
, body: StatementsNode
| BeginNode
| nil, end_keyword_loc
: Location
, name: Symbol }
# File prism/node.rb, line 12925 def deconstruct_keys(keys) { node_id: node_id, location: location, locals: locals, module_keyword_loc: module_keyword_loc, constant_path: constant_path, body: body, end_keyword_loc: end_keyword_loc, name: name } end
def end_keyword
: () -> String
# File prism/node.rb, line 12973 def end_keyword end_keyword_loc.slice end
attr_reader end_keyword_loc
: Location
# File prism/node.rb, line 12952 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
def inspect -> String
# File prism/node.rb, line 12978 def inspect InspectVisitor.compose(self) end
def module_keyword
: () -> String
# File prism/node.rb, line 12968 def module_keyword module_keyword_loc.slice end
attr_reader module_keyword_loc
: Location
# File prism/node.rb, line 12933 def module_keyword_loc location = @module_keyword_loc return location if location.is_a?(Location) @module_keyword_loc = Location.new(source, location >> 32, location & 0xFFFFFFFF) end
使用给定的保存源保存 end_keyword_loc
位置,以便稍后检索。
# File prism/node.rb, line 12960 def save_end_keyword_loc(repository) repository.enter(node_id, :end_keyword_loc) end
使用给定的保存源保存 module_keyword_loc
位置,以便稍后检索。
# File prism/node.rb, line 12941 def save_module_keyword_loc(repository) repository.enter(node_id, :module_keyword_loc) end
返回此节点类型的符号表示。请参阅 'Node#type'。
# File prism/node.rb, line 12983 def type :module_node end