Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
class method
ErrorHighlight.find_node_from_loc
find_node_from_loc(loc)
lib/error_highlight/base.rb
View on GitHub ↗
# File tmp/rubies/ruby-4.1.0-preview1/lib/error_highlight/base.rb, line 75
def self.find_node_from_loc(loc)
if loc.respond_to?(:syntax_tree)
return loc.syntax_tree
end
begin
RubyVM::AbstractSyntaxTree.of(loc, keep_script_lines: true)
rescue RuntimeError => error
# RubyVM::AbstractSyntaxTree.of raises an error with a message that
# includes "prism" when the ISEQ was compiled with the prism compiler.
# In this case, we'll try to parse again with prism instead.
raise unless error.message.include?("prism")
prism_find(loc)
end
end
No documentation available