Skip to content

Commit 9b31275

Browse files
authored
Make module tracking lazy (#1978)
1 parent 1639dd4 commit 9b31275

File tree

1 file changed

+9
-19
lines changed
  • lib/ruby_indexer/lib/ruby_indexer

1 file changed

+9
-19
lines changed

lib/ruby_indexer/lib/ruby_indexer/entry.rb

Lines changed: 9 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -60,29 +60,19 @@ class Namespace < Entry
6060

6161
abstract!
6262

63-
sig { returns(T::Array[String]) }
64-
attr_accessor :included_modules
63+
sig { returns(String) }
64+
def short_name
65+
T.must(@name.split("::").last)
66+
end
6567

6668
sig { returns(T::Array[String]) }
67-
attr_accessor :prepended_modules
68-
69-
sig do
70-
params(
71-
name: String,
72-
file_path: String,
73-
location: T.any(Prism::Location, RubyIndexer::Location),
74-
comments: T::Array[String],
75-
).void
76-
end
77-
def initialize(name, file_path, location, comments)
78-
super(name, file_path, location, comments)
79-
@included_modules = T.let([], T::Array[String])
80-
@prepended_modules = T.let([], T::Array[String])
69+
def included_modules
70+
@included_modules ||= T.let([], T.nilable(T::Array[String]))
8171
end
8272

83-
sig { returns(String) }
84-
def short_name
85-
T.must(@name.split("::").last)
73+
sig { returns(T::Array[String]) }
74+
def prepended_modules
75+
@prepended_modules ||= T.let([], T.nilable(T::Array[String]))
8676
end
8777
end
8878

0 commit comments

Comments
 (0)