From 9b31275d18007cec25fd697c065f94d4f197f38c Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 26 Apr 2024 09:41:54 -0400 Subject: [PATCH] Make module tracking lazy (#1978) --- lib/ruby_indexer/lib/ruby_indexer/entry.rb | 28 +++++++--------------- 1 file changed, 9 insertions(+), 19 deletions(-) diff --git a/lib/ruby_indexer/lib/ruby_indexer/entry.rb b/lib/ruby_indexer/lib/ruby_indexer/entry.rb index f5e7a3687..d9e17e2db 100644 --- a/lib/ruby_indexer/lib/ruby_indexer/entry.rb +++ b/lib/ruby_indexer/lib/ruby_indexer/entry.rb @@ -60,29 +60,19 @@ class Namespace < Entry abstract! - sig { returns(T::Array[String]) } - attr_accessor :included_modules + sig { returns(String) } + def short_name + T.must(@name.split("::").last) + end sig { returns(T::Array[String]) } - attr_accessor :prepended_modules - - sig do - params( - name: String, - file_path: String, - location: T.any(Prism::Location, RubyIndexer::Location), - comments: T::Array[String], - ).void - end - def initialize(name, file_path, location, comments) - super(name, file_path, location, comments) - @included_modules = T.let([], T::Array[String]) - @prepended_modules = T.let([], T::Array[String]) + def included_modules + @included_modules ||= T.let([], T.nilable(T::Array[String])) end - sig { returns(String) } - def short_name - T.must(@name.split("::").last) + sig { returns(T::Array[String]) } + def prepended_modules + @prepended_modules ||= T.let([], T.nilable(T::Array[String])) end end