class Orbacle::FindDefinitionUnderPosition
Constants
- ConstantResult
- MessageResult
- SuperResult
Attributes
parser[R]
Public Class Methods
new(parser)
click to toggle source
# File lib/orbacle/find_definition_under_position.rb, line 13 def initialize(parser) @parser = parser end
Public Instance Methods
on_class(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_definition_under_position.rb, line 43 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_const(ast)
click to toggle source
# File lib/orbacle/find_definition_under_position.rb, line 36 def on_const(ast) if build_position_range_from_ast(ast).include_position?(@searched_position) @result = ConstantResult.new(ConstRef.from_ast(ast, @current_nesting)) end nil end
on_module(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_definition_under_position.rb, line 52 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_definition_under_position.rb, line 61 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) if message_name.equal?(:[]) selector_position_range = build_position_range_from_parser_range(ast.loc.selector) if selector_position_range.on_edges?(@searched_position) @result = MessageResult.new(message_name, selector_position_range) else super end else selector_position_range = build_position_range_from_parser_range(ast.loc.selector) @result = MessageResult.new(message_name, selector_position_range) end elsif ast.loc.dot && build_position_range_from_parser_range(ast.loc.dot).include_position?(@searched_position) message_name = ast.children.fetch(1) dot_position_range = build_position_range_from_parser_range(ast.loc.dot) @result = MessageResult.new(message_name, dot_position_range) else super end nil end
on_super(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_definition_under_position.rb, line 85 def on_super(ast) keyword_position_range = build_position_range_from_parser_range(ast.loc.keyword) if keyword_position_range.include_position?(@searched_position) @result = SuperResult.new(keyword_position_range) else super end nil end
on_zsuper(ast)
click to toggle source
# File lib/orbacle/find_definition_under_position.rb, line 95 def on_zsuper(ast) keyword_position_range = build_position_range_from_parser_range(ast.loc.keyword) if keyword_position_range.include_position?(@searched_position) @result = SuperResult.new(keyword_position_range) end nil end
process(ast)
click to toggle source
Calls superclass method
# File lib/orbacle/find_definition_under_position.rb, line 30 def process(ast) new_ast = super raise unless ast.equal?(new_ast) new_ast end
process_file(file_content, searched_position)
click to toggle source
# File lib/orbacle/find_definition_under_position.rb, line 17 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_definition_under_position.rb, line 103 def with_new_nesting(new_nesting) previous_nesting = @current_nesting @current_nesting = new_nesting yield @current_nesting = previous_nesting end