From: "tenderlovemaking (Aaron Patterson) via ruby-core" Date: 2025-01-08T04:55:36+00:00 Subject: [ruby-core:120550] [Ruby master Feature#21005] Update the source location method to include line start/stop and column start/stop details Issue #21005 has been updated by tenderlovemaking (Aaron Patterson). mame (Yusuke Endoh) wrote in #note-12: > tenderlovemaking (Aaron Patterson) wrote in #note-11: > > I think we should add a reader method on RubyVM::InstructionSequence to get the node id. > > I don't think it is good for a user to handle `node_id` explicitly. > Rather, I think Prism should provide a simple method to directly retrieve a node subtree of a Method/Proc object given, like `RubyVM::AST.of`. I agree. The problem is that `RubyVM::AST` is built in to Ruby, so it has access to `rb_iseq_t` members. Prism cannot access fields on `rb_iseq_t`. My idea is to apply a patch like this to iseq.c: https://github.com/tenderlove/ruby/commit/9a54230012d8837a981e0ddec88384ab6ef4db89 Then add code to Prism like this: ```ruby require "prism" # Put the following code in Prism module Prism def self.ast_for iseq ast = Prism.parse(File.read(iseq.absolute_path)) node_id = iseq.node_id ast.value.breadth_first_search { |node| node.node_id == node_id } end end # User code is below f = proc { <