class Prism::NodeFind::RubyVMCallableFind - Documentation for Ruby 4.1
Description: class Prism::NodeFind::RubyVMCallableFind: Finds the AST node for a Method, UnboundMethod, or Proc using the node_id from the instruction sequence.
Keywords: ruby,class,Prism::NodeFind::RubyVMCallableFind

🔍

No recent searches

# class Prism::NodeFind::RubyVMCallableFind

Finds the AST node for a Method, `UnboundMethod`, or `Proc` using the node_id from the instruction sequence.

### Public Instance Methods

find (callable)
Source

    # File lib/prism/node_find.rb, line 65
    def find(callable)
      return unless (source_location = callable.source_location)
      return unless (result = parse_file(source_location[0]))
      return unless (iseq = RubyVM::InstructionSequence.of(callable))

      header = iseq.to_a[4]
      return unless header[:parser] == :prism

      result.value.find { |node| node.node_id == header[:node_id] }
    end

`Find` the node for the given callable using the ISeq node_id.