Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove unnecessary uses of extend T::Sig #3257

Merged
merged 1 commit into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ module RubyLsp
# end
# end
class UseRegisterWithHandlerMethod < RuboCop::Cop::Base
extend T::Sig

MSG_MISSING_HANDLER = "Registered to `%{listener}` without a handler defined."
MSG_MISSING_LISTENER = "Created a handler without registering the associated `%{listener}` event."

Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_indexer/lib/ruby_indexer/configuration.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module RubyIndexer
class Configuration
extend T::Sig

CONFIGURATION_SCHEMA = T.let(
{
"excluded_gems" => Array,
Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module RubyIndexer
class DeclarationListener
extend T::Sig

OBJECT_NESTING = T.let(["Object"].freeze, T::Array[String])
BASIC_OBJECT_NESTING = T.let(["BasicObject"].freeze, T::Array[String])

Expand Down
23 changes: 0 additions & 23 deletions lib/ruby_indexer/lib/ruby_indexer/entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ class Visibility < T::Enum
end
end

extend T::Sig

#: String
attr_reader :name

Expand Down Expand Up @@ -171,8 +169,6 @@ class Module < Namespace
end

class Class < Namespace
extend T::Sig

# The unresolved name of the parent class. This may return `nil`, which indicates the lack of an explicit parent
# and therefore ::Object is the correct parent class
#: String?
Expand All @@ -192,8 +188,6 @@ def ancestor_hash
end

class SingletonClass < Class
extend T::Sig

#: (Location location, Location name_location, String? comments) -> void
def update_singleton_information(location, name_location, comments)
@location = location
Expand Down Expand Up @@ -282,7 +276,6 @@ class BlockParameter < Parameter
DEFAULT_NAME = T.let(:"<anonymous block>", Symbol)

class << self
extend T::Sig
#: -> BlockParameter
def anonymous
new(name: DEFAULT_NAME)
Expand All @@ -298,8 +291,6 @@ def decorated_name

# A forwarding method parameter, e.g. `def foo(...)`
class ForwardingParameter < Parameter
extend T::Sig

#: -> void
def initialize
# You can't name a forwarding parameter, it's always called `...`
Expand Down Expand Up @@ -349,8 +340,6 @@ def formatted_signatures
end

class Accessor < Member
extend T::Sig

# @override
#: -> Array[Signature]
def signatures
Expand All @@ -366,8 +355,6 @@ def signatures
end

class Method < Member
extend T::Sig

#: Array[Signature]
attr_reader :signatures

Expand All @@ -394,8 +381,6 @@ def initialize(name, uri, location, name_location, comments, signatures, visibil
# target in [rdoc-ref:Index#resolve]. If the right hand side contains a constant that doesn't exist, then it's not
# possible to resolve the alias and it will remain an UnresolvedAlias until the right hand side constant exists
class UnresolvedConstantAlias < Entry
extend T::Sig

#: String
attr_reader :target

Expand All @@ -413,8 +398,6 @@ def initialize(target, nesting, name, uri, location, comments) # rubocop:disable

# Alias represents a resolved alias, which points to an existing constant target
class ConstantAlias < Entry
extend T::Sig

#: String
attr_reader :target

Expand Down Expand Up @@ -463,8 +446,6 @@ def initialize(name, uri, location, comments, owner)
# example, if we have `alias a b`, we create an unresolved alias for `a` because we aren't sure immediate what `b`
# is referring to
class UnresolvedMethodAlias < Entry
extend T::Sig

#: String
attr_reader :new_name, :old_name

Expand All @@ -483,8 +464,6 @@ def initialize(new_name, old_name, owner, uri, location, comments) # rubocop:dis

# A method alias is a resolved alias entry that points to the exact method target it refers to
class MethodAlias < Entry
extend T::Sig

#: (Member | MethodAlias)
attr_reader :target

Expand Down Expand Up @@ -528,8 +507,6 @@ def signatures
# However RBS can represent the concept of method overloading, with different return types based on the arguments
# passed, so we need to store all the signatures.
class Signature
extend T::Sig

#: Array[Parameter]
attr_reader :parameters

Expand Down
4 changes: 0 additions & 4 deletions lib/ruby_indexer/lib/ruby_indexer/index.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module RubyIndexer
class Index
extend T::Sig

class UnresolvableAliasError < StandardError; end
class NonExistingNamespaceError < StandardError; end
class IndexNotEmptyError < StandardError; end
Expand All @@ -16,8 +14,6 @@ class IndexNotEmptyError < StandardError; end
attr_reader :configuration

class << self
extend T::Sig

# Returns the real nesting of a constant name taking into account top level
# references that may be included anywhere in the name or nesting where that
# constant was found
Expand Down
4 changes: 0 additions & 4 deletions lib/ruby_indexer/lib/ruby_indexer/location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,7 @@

module RubyIndexer
class Location
extend T::Sig

class << self
extend T::Sig

#: (Prism::Location prism_location, (^(Integer arg0) -> Integer | Prism::CodeUnitsCache) code_units_cache) -> instance
def from_prism_location(prism_location, code_units_cache)
new(
Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_indexer/lib/ruby_indexer/prefix_tree.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ module RubyIndexer
#
# See https://en.wikipedia.org/wiki/Trie for more information
class PrefixTree
extend T::Sig
extend T::Generic

Value = type_member
Expand Down Expand Up @@ -108,7 +107,6 @@ def find_node(key)
end

class Node
extend T::Sig
extend T::Generic

Value = type_member
Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_indexer/lib/ruby_indexer/rbs_indexer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module RubyIndexer
class RBSIndexer
extend T::Sig

HAS_UNTYPED_FUNCTION = T.let(!!defined?(RBS::Types::UntypedFunction), T::Boolean)

#: (Index index) -> void
Expand Down
10 changes: 0 additions & 10 deletions lib/ruby_indexer/lib/ruby_indexer/reference_finder.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,13 @@

module RubyIndexer
class ReferenceFinder
extend T::Sig

class Target
extend T::Helpers

abstract!
end

class ConstTarget < Target
extend T::Sig

#: String
attr_reader :fully_qualified_name

Expand All @@ -25,8 +21,6 @@ def initialize(fully_qualified_name)
end

class MethodTarget < Target
extend T::Sig

#: String
attr_reader :method_name

Expand All @@ -38,8 +32,6 @@ def initialize(method_name)
end

class InstanceVariableTarget < Target
extend T::Sig

#: String
attr_reader :name

Expand All @@ -51,8 +43,6 @@ def initialize(name)
end

class Reference
extend T::Sig

#: String
attr_reader :name

Expand Down
4 changes: 0 additions & 4 deletions lib/ruby_indexer/lib/ruby_indexer/visibility_scope.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,7 @@ module RubyIndexer
# Represents the visibility scope in a Ruby namespace. This keeps track of whether methods are in a public, private or
# protected section, and whether they are module functions.
class VisibilityScope
extend T::Sig

class << self
extend T::Sig

#: -> instance
def module_function_scope
new(module_func: true, visibility: Entry::Visibility::PRIVATE)
Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_lsp/addon.rb
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ class Addon
class IncompatibleApiError < StandardError; end

class << self
extend T::Sig

#: Array[Addon]
attr_accessor :addons

Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_lsp/client_capabilities.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ module RubyLsp
# This class stores all client capabilities that the Ruby LSP and its add-ons depend on to ensure that we're
# not enabling functionality unsupported by the editor connecting to the server
class ClientCapabilities
extend T::Sig

#: bool
attr_reader :supports_watching_files,
:supports_request_delegation,
Expand Down
3 changes: 0 additions & 3 deletions lib/ruby_lsp/erb_document.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

module RubyLsp
class ERBDocument < Document
extend T::Sig
extend T::Generic

ParseResultType = type_member { { fixed: Prism::ParseResult } }
Expand Down Expand Up @@ -73,8 +72,6 @@ def inside_host_language?(char_position)
end

class ERBScanner
extend T::Sig

#: String
attr_reader :ruby, :host_language

Expand Down
2 changes: 0 additions & 2 deletions lib/ruby_lsp/global_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@

module RubyLsp
class GlobalState
extend T::Sig

#: String
attr_reader :test_library

Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/code_lens.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module RubyLsp
module Listeners
class CodeLens
extend T::Sig
include Requests::Support::Common

BASE_COMMAND = T.let(
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class Completion
extend T::Sig
include Requests::Support::Common

KEYWORDS = [
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class Definition
extend T::Sig
include Requests::Support::Common

MAX_NUMBER_OF_DEFINITION_CANDIDATES_WITHOUT_RECEIVER = 10
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/document_highlight.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class DocumentHighlight
extend T::Sig
include Requests::Support::Common

GLOBAL_VARIABLE_NODES = T.let(
Expand Down
3 changes: 0 additions & 3 deletions lib/ruby_lsp/listeners/document_link.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@
module RubyLsp
module Listeners
class DocumentLink
extend T::Sig
include Requests::Support::Common

GEM_TO_VERSION_MAP = T.let(
Expand All @@ -17,8 +16,6 @@ class DocumentLink
)

class << self
extend T::Sig

#: -> Hash[String, Hash[String, Hash[String, String]]]
def gem_paths
@gem_paths ||= T.let(
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/document_symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class DocumentSymbol
extend T::Sig
include Requests::Support::Common

ATTR_ACCESSORS = T.let([:attr_reader, :attr_writer, :attr_accessor].freeze, T::Array[Symbol])
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/folding_ranges.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class FoldingRanges
extend T::Sig
include Requests::Support::Common

#: (ResponseBuilders::CollectionResponseBuilder[Interface::FoldingRange] response_builder, Array[Prism::Comment] comments, Prism::Dispatcher dispatcher) -> void
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/hover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class Hover
extend T::Sig
include Requests::Support::Common

ALLOWED_TARGETS = T.let(
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/inlay_hints.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class InlayHints
extend T::Sig
include Requests::Support::Common

RESCUE_STRING_LENGTH = T.let("rescue".length, Integer)
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/semantic_highlighting.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ module RubyLsp
module Listeners
class SemanticHighlighting
include Requests::Support::Common
extend T::Sig

SPECIAL_RUBY_METHODS = T.let(
[
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/signature_help.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
module RubyLsp
module Listeners
class SignatureHelp
extend T::Sig
include Requests::Support::Common

#: (ResponseBuilders::SignatureHelp response_builder, GlobalState global_state, NodeContext node_context, Prism::Dispatcher dispatcher, RubyDocument::SorbetLevel sorbet_level) -> void
Expand Down
1 change: 0 additions & 1 deletion lib/ruby_lsp/listeners/test_style.rb
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,6 @@ def handle_test_unit_groups(file_path, groups_and_examples)
end
end

extend T::Sig
include Requests::Support::Common

ACCESS_MODIFIERS = [:public, :private, :protected].freeze
Expand Down
Loading