Class: Prism::NodeFind::LineMethodFind
| Relationships & Source Files | |
| Super Chains via Extension / Inclusion / Inheritance | |
|
Class Chain:
self,
Find
|
|
|
Instance Chain:
self,
Find
|
|
| Inherits: |
Prism::NodeFind::Find
|
| Defined in: | lib/prism/node_find.rb |
Overview
Finds the AST node for a Method or UnboundMethod using best-effort line matching. Used on non-CRuby implementations.
Instance Method Summary
-
#find(callable)
Findthe node for the given method by matching on name and line.
Find - Inherited
| #parse_file | Parse the given file path, returning a |
Instance Method Details
#find(callable)
Find the node for the given method by matching on name and line.
# File 'lib/prism/node_find.rb', line 100
def find(callable) return unless (source_location = callable.source_location) return unless (result = parse_file(source_location[0])) name = callable.name start_line = source_location[1] result.value.find do |node| case node when DefNode node.name == name && node.location.start_line == start_line when CallNode node.block.is_a?(BlockNode) && node.location.start_line == start_line else false end end end