Skip to content

Commit

Permalink
Move to_ruby_indexer_location to class method
Browse files Browse the repository at this point in the history
  • Loading branch information
andyw8 committed Jun 7, 2024
1 parent 084a1e3 commit 4787ae6
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,20 @@ module RubyIndexer
class RBSIndexer
extend T::Sig

class << self
extend T::Sig

sig { params(rbs_location: RBS::Location).returns(RubyIndexer::Location) }
def to_ruby_indexer_location(rbs_location)
RubyIndexer::Location.new(
rbs_location.start_line,
rbs_location.end_line,
rbs_location.start_column,
rbs_location.end_column,
)
end
end

sig { params(index: Index).void }
def initialize(index)
@index = index
Expand Down Expand Up @@ -43,21 +57,11 @@ def process_declaration(declaration, pathname)
def handle_class_declaration(declaration, pathname)
nesting = [declaration.name.name.to_s]
file_path = pathname.to_s
location = to_ruby_indexer_location(declaration.location)
location = self.class.to_ruby_indexer_location(declaration.location)
comments = Array(declaration.comment&.string)
parent_class = declaration.super_class&.name&.name&.to_s
class_entry = Entry::Class.new(nesting, file_path, location, comments, parent_class)
@index << class_entry
end

sig { params(rbs_location: RBS::Location).returns(RubyIndexer::Location) }
def to_ruby_indexer_location(rbs_location)
RubyIndexer::Location.new(
rbs_location.start_line,
rbs_location.end_line,
rbs_location.start_column,
rbs_location.end_column,
)
end
end
end

0 comments on commit 4787ae6

Please sign in to comment.