Skip to content

Commit

Permalink
Document the decision to store a single location for SingletonClass
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Jun 10, 2024
1 parent af2b07b commit 54c57d3
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions lib/ruby_indexer/lib/ruby_indexer/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,9 @@ def ancestor_hash
class SingletonClass < Class
extend T::Sig

# Ruby allows you to create as many singleton blocks inside the same file as you want. However, we only store
# whatever the latest location is. We could store the location of every single block to offer all of them as
# options when going to definition for `Foo.singleton_class`, but it's probably not worth the extra memory usage
sig { params(location: Prism::Location).void }
def update_location(location)
@location = Location.new(
Expand Down

0 comments on commit 54c57d3

Please sign in to comment.