class Prism::NodeFind::LineProcFind - Documentation for Ruby 4.1
Description: class Prism::NodeFind::LineProcFind: Finds the AST node for a non-lambda Proc using best-effort line matching. Used on non-CRuby implementations.
Keywords: ruby,class,Prism::NodeFind::LineProcFind

🔍

No recent searches

# class Prism::NodeFind::LineProcFind

Finds the AST node for a non-lambda `Proc` using best-effort line matching. Used on non-CRuby implementations.

### Public Instance Methods

find (callable)
Source

    # File lib/prism/node_find.rb, line 151
    def find(callable)
      return unless (source_location = callable.source_location)
      return unless (result = parse_file(source_location[0]))

      start_line = source_location[1]

      result.value.find do |node|
        case node
        when ForNode
          node.location.start_line == start_line
        when CallNode
          node.block.is_a?(BlockNode) && node.location.start_line == start_line
        else
          false
        end
      end
    end

`Find` the node for the given proc by matching on line.