ruby / rbs

Type Signature for Ruby
Other
1.94k stars 211 forks source link

Handle ISEQs compiled by Prism #1983

Closed kddnewton closed 1 month ago

soutaro commented 1 month ago

Hi @kddnewton!

Does it mean getting an AST from method at runtime is not supported in prism? Or we can do equivalent using other API? Right now or in the future?

XrXr commented 1 month ago

@soutaro I think error_highlight does something similar to what you need with Prism: https://github.com/ruby/ruby/blob/eef2121cf3e755cdf33538647d40993d296f9a04/lib/error_highlight/base.rb#L58-L65

Like RubyVM::AST.of, it's re-parsing then finding a node.

soutaro commented 1 month ago

@XrXr Got it! Thank you very much.

kddnewton commented 4 weeks ago

@soutaro basically exactly what Alan said. This method https://github.com/ruby/ruby/blob/eef2121cf3e755cdf33538647d40993d296f9a04/lib/error_highlight/base.rb#L86-L95 does effectively the same thing.