Skip to content

Commit

Permalink
Extract duplication
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Oct 17, 2023
1 parent cd3547b commit 9350f23
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions lib/ruby_indexer/lib/ruby_indexer/visitor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -132,16 +132,19 @@ def visit_call_node(node)
def visit_def_node(node)
method_name = node.name.to_s
comments = collect_comments(node)
case node.receiver
entry_class = case node.receiver
when nil
@index << if @singleton
Entry::SingletonMethod.new(method_name, @file_path, node.location, comments, node.parameters)
if @singleton
Entry::SingletonMethod
else
Entry::InstanceMethod.new(method_name, @file_path, node.location, comments, node.parameters)
Entry::InstanceMethod
end
when Prism::SelfNode
@index << Entry::SingletonMethod.new(method_name, @file_path, node.location, comments, node.parameters)
Entry::SingletonMethod
else
return
end
@index << entry_class.new(method_name, @file_path, node.location, comments, node.parameters)
end

private
Expand Down

0 comments on commit 9350f23

Please sign in to comment.