lib/ruby_indexer/lib/ruby_indexer/entry.rb in ruby-lsp-0.19.1 vs lib/ruby_indexer/lib/ruby_indexer/entry.rb in ruby-lsp-0.20.0
- old
+ new
@@ -29,34 +29,20 @@
sig do
params(
name: String,
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
+ location: Location,
comments: T.nilable(String),
- encoding: Encoding,
).void
end
- def initialize(name, file_path, location, comments, encoding)
+ def initialize(name, file_path, location, comments)
@name = name
@file_path = file_path
@comments = comments
@visibility = T.let(Visibility::PUBLIC, Visibility)
-
- @location = T.let(
- if location.is_a?(Prism::Location)
- Location.new(
- location.start_line,
- location.end_line,
- location.start_code_units_column(encoding),
- location.end_code_units_column(encoding),
- )
- else
- location
- end,
- RubyIndexer::Location,
- )
+ @location = location
end
sig { returns(T::Boolean) }
def public?
visibility == Visibility::PUBLIC
@@ -150,36 +136,23 @@
sig do
params(
nesting: T::Array[String],
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
- name_location: T.any(Prism::Location, Location),
+ location: Location,
+ name_location: Location,
comments: T.nilable(String),
- encoding: Encoding,
).void
end
- def initialize(nesting, file_path, location, name_location, comments, encoding) # rubocop:disable Metrics/ParameterLists
+ def initialize(nesting, file_path, location, name_location, comments)
@name = T.let(nesting.join("::"), String)
# The original nesting where this namespace was discovered
@nesting = nesting
- super(@name, file_path, location, comments, encoding)
+ super(@name, file_path, location, comments)
- @name_location = T.let(
- if name_location.is_a?(Prism::Location)
- Location.new(
- name_location.start_line,
- name_location.end_line,
- name_location.start_code_units_column(encoding),
- name_location.end_code_units_column(encoding),
- )
- else
- name_location
- end,
- RubyIndexer::Location,
- )
+ @name_location = name_location
end
sig { returns(T::Array[String]) }
def mixin_operation_module_names
mixin_operations.map(&:module_name)
@@ -212,19 +185,18 @@
sig do
params(
nesting: T::Array[String],
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
- name_location: T.any(Prism::Location, Location),
+ location: Location,
+ name_location: Location,
comments: T.nilable(String),
- encoding: Encoding,
parent_class: T.nilable(String),
).void
end
- def initialize(nesting, file_path, location, name_location, comments, encoding, parent_class) # rubocop:disable Metrics/ParameterLists
- super(nesting, file_path, location, name_location, comments, encoding)
+ def initialize(nesting, file_path, location, name_location, comments, parent_class) # rubocop:disable Metrics/ParameterLists
+ super(nesting, file_path, location, name_location, comments)
@parent_class = parent_class
end
sig { override.returns(Integer) }
def ancestor_hash
@@ -235,30 +207,18 @@
class SingletonClass < Class
extend T::Sig
sig do
params(
- location: Prism::Location,
- name_location: Prism::Location,
+ location: Location,
+ name_location: Location,
comments: T.nilable(String),
- encoding: Encoding,
).void
end
- def update_singleton_information(location, name_location, comments, encoding)
- # Create a new RubyIndexer::Location object from the Prism location
- @location = Location.new(
- location.start_line,
- location.end_line,
- location.start_code_units_column(encoding),
- location.end_code_units_column(encoding),
- )
- @name_location = Location.new(
- name_location.start_line,
- name_location.end_line,
- name_location.start_code_units_column(encoding),
- name_location.end_code_units_column(encoding),
- )
+ def update_singleton_information(location, name_location, comments)
+ @location = location
+ @name_location = name_location
(@comments ||= +"") << comments if comments
end
end
class Constant < Entry
@@ -371,19 +331,18 @@
sig do
params(
name: String,
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
+ location: Location,
comments: T.nilable(String),
- encoding: Encoding,
visibility: Visibility,
owner: T.nilable(Entry::Namespace),
).void
end
- def initialize(name, file_path, location, comments, encoding, visibility, owner) # rubocop:disable Metrics/ParameterLists
- super(name, file_path, location, comments, encoding)
+ def initialize(name, file_path, location, comments, visibility, owner) # rubocop:disable Metrics/ParameterLists
+ super(name, file_path, location, comments)
@visibility = visibility
@owner = owner
end
sig { abstract.returns(T::Array[Entry::Signature]) }
@@ -439,35 +398,22 @@
sig do
params(
name: String,
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
- name_location: T.any(Prism::Location, Location),
+ location: Location,
+ name_location: Location,
comments: T.nilable(String),
- encoding: Encoding,
signatures: T::Array[Signature],
visibility: Visibility,
owner: T.nilable(Entry::Namespace),
).void
end
- def initialize(name, file_path, location, name_location, comments, encoding, signatures, visibility, owner) # rubocop:disable Metrics/ParameterLists
- super(name, file_path, location, comments, encoding, visibility, owner)
+ def initialize(name, file_path, location, name_location, comments, signatures, visibility, owner) # rubocop:disable Metrics/ParameterLists
+ super(name, file_path, location, comments, visibility, owner)
@signatures = signatures
- @name_location = T.let(
- if name_location.is_a?(Prism::Location)
- Location.new(
- name_location.start_line,
- name_location.end_line,
- name_location.start_code_units_column(encoding),
- name_location.end_code_units_column(encoding),
- )
- else
- name_location
- end,
- RubyIndexer::Location,
- )
+ @name_location = name_location
end
end
# An UnresolvedAlias points to a constant alias with a right hand side that has not yet been resolved. For
# example, if we find
@@ -492,17 +438,16 @@
params(
target: String,
nesting: T::Array[String],
name: String,
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
+ location: Location,
comments: T.nilable(String),
- encoding: Encoding,
).void
end
- def initialize(target, nesting, name, file_path, location, comments, encoding) # rubocop:disable Metrics/ParameterLists
- super(name, file_path, location, comments, encoding)
+ def initialize(target, nesting, name, file_path, location, comments) # rubocop:disable Metrics/ParameterLists
+ super(name, file_path, location, comments)
@target = target
@nesting = nesting
end
end
@@ -512,18 +457,17 @@
extend T::Sig
sig { returns(String) }
attr_reader :target
- sig { params(target: String, unresolved_alias: UnresolvedConstantAlias, encoding: Encoding).void }
- def initialize(target, unresolved_alias, encoding)
+ sig { params(target: String, unresolved_alias: UnresolvedConstantAlias).void }
+ def initialize(target, unresolved_alias)
super(
unresolved_alias.name,
unresolved_alias.file_path,
unresolved_alias.location,
unresolved_alias.comments,
- encoding
)
@visibility = unresolved_alias.visibility
@target = target
end
@@ -539,18 +483,17 @@
sig do
params(
name: String,
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
+ location: Location,
comments: T.nilable(String),
- encoding: Encoding,
owner: T.nilable(Entry::Namespace),
).void
end
- def initialize(name, file_path, location, comments, encoding, owner) # rubocop:disable Metrics/ParameterLists
- super(name, file_path, location, comments, encoding)
+ def initialize(name, file_path, location, comments, owner)
+ super(name, file_path, location, comments)
@owner = owner
end
end
# An unresolved method alias is an alias entry for which we aren't sure what the right hand side points to yet. For
@@ -569,17 +512,16 @@
params(
new_name: String,
old_name: String,
owner: T.nilable(Entry::Namespace),
file_path: String,
- location: T.any(Prism::Location, RubyIndexer::Location),
+ location: Location,
comments: T.nilable(String),
- encoding: Encoding,
).void
end
- def initialize(new_name, old_name, owner, file_path, location, comments, encoding) # rubocop:disable Metrics/ParameterLists
- super(new_name, file_path, location, comments, encoding)
+ def initialize(new_name, old_name, owner, file_path, location, comments) # rubocop:disable Metrics/ParameterLists
+ super(new_name, file_path, location, comments)
@new_name = new_name
@old_name = old_name
@owner = owner
end
@@ -594,22 +536,21 @@
sig { returns(T.nilable(Entry::Namespace)) }
attr_reader :owner
sig do
- params(target: T.any(Member, MethodAlias), unresolved_alias: UnresolvedMethodAlias, encoding: Encoding).void
+ params(target: T.any(Member, MethodAlias), unresolved_alias: UnresolvedMethodAlias).void
end
- def initialize(target, unresolved_alias, encoding)
+ def initialize(target, unresolved_alias)
full_comments = +"Alias for #{target.name}\n"
full_comments << "#{unresolved_alias.comments}\n"
full_comments << target.comments
super(
unresolved_alias.new_name,
unresolved_alias.file_path,
unresolved_alias.location,
full_comments,
- encoding
)
@target = target
@owner = T.let(unresolved_alias.owner, T.nilable(Entry::Namespace))
end