class Orbacle::FindCallUnderPosition
Constants
- IvarResult
- SelfResult
Attributes
parser[R]
Public Class Methods
new(parser)
click to toggle source
# File lib/orbacle/find_call_under_position.rb, line 12 def initialize(parser) @parser = parser end
Public Instance Methods
on_class(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_call_under_position.rb, line 50 def on_class(ast) klass_name_ast, _ = ast.children klass_name_ref = ConstRef.from_ast(klass_name_ast, @current_nesting) with_new_nesting(@current_nesting.increase_nesting_const(klass_name_ref)) do super end nil end
on_module(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_call_under_position.rb, line 59 def on_module(ast) module_name_ast, _ = ast.children module_name_ref = ConstRef.from_ast(module_name_ast, @current_nesting) with_new_nesting(@current_nesting.increase_nesting_const(module_name_ref)) do super end nil end
on_send(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_call_under_position.rb, line 29 def on_send(ast) if ast.loc.selector && build_position_range_from_parser_range(ast.loc.selector).include_position?(@searched_position) message_name = ast.children.fetch(1) selector_position_range = build_position_range_from_parser_range(ast.loc.selector) @result = if ast.children[0] == nil SelfResult.new(message_name, @current_nesting) else case ast.children[0].type when :self SelfResult.new(message_name, @current_nesting) when :ivar IvarResult.new(message_name, ast.children[0].children[0], @current_nesting) else end end else super end nil end
process_file(file_content, searched_position)
click to toggle source
# File lib/orbacle/find_call_under_position.rb, line 16 def process_file(file_content, searched_position) ast = parser.parse(file_content) @current_nesting = Nesting.empty @searched_position = searched_position process(ast) @result end
with_new_nesting(new_nesting) { || ... }
click to toggle source
# File lib/orbacle/find_call_under_position.rb, line 68 def with_new_nesting(new_nesting) previous_nesting = @current_nesting @current_nesting = new_nesting yield @current_nesting = previous_nesting end