From 1bbc5ce03b3e2113f0ba3402dae8ba2b2f3c781e Mon Sep 17 00:00:00 2001 From: Andy Waite <13400+andyw8@users.noreply.github.com> Date: Thu, 21 Nov 2024 07:54:22 -0500 Subject: [PATCH] Update for changes to enhancements API --- Gemfile | 2 - Gemfile.lock | 23 +- lib/ruby_lsp/ruby_lsp_rails/addon.rb | 1 - .../ruby_lsp_rails/indexing_enhancement.rb | 78 +++--- ruby-lsp-rails.gemspec | 2 +- ...0fbdf40b8545c3.rbi => ruby-lsp@0.22.0.rbi} | 229 +++++++++--------- test/dummy/app/models/concerns/verifiable.rb | 16 ++ test/dummy/app/models/user.rb | 2 + .../indexing_enhancement_test.rb | 2 - 9 files changed, 166 insertions(+), 189 deletions(-) rename sorbet/rbi/gems/{ruby-lsp@0.21.4-bb3a5b25da4ba2931278fdeb1f0fbdf40b8545c3.rbi => ruby-lsp@0.22.0.rbi} (98%) create mode 100644 test/dummy/app/models/concerns/verifiable.rb diff --git a/Gemfile b/Gemfile index 583a70fe..17006b00 100644 --- a/Gemfile +++ b/Gemfile @@ -23,5 +23,3 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do gem "tzinfo" gem "tzinfo-data" end - -gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "11-14-allow_indexing_enhancements_to_create_namespaces" diff --git a/Gemfile.lock b/Gemfile.lock index 82f12460..8c00f186 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,19 +1,8 @@ -GIT - remote: https://github.com/Shopify/ruby-lsp.git - revision: bb3a5b25da4ba2931278fdeb1f0fbdf40b8545c3 - branch: 11-14-allow_indexing_enhancements_to_create_namespaces - specs: - ruby-lsp (0.21.4) - language_server-protocol (~> 3.17.0) - prism (>= 1.2, < 2.0) - rbs (>= 3, < 4) - sorbet-runtime (>= 0.5.10782) - PATH remote: . specs: ruby-lsp-rails (0.3.26) - ruby-lsp (>= 0.21.2, < 0.22.0) + ruby-lsp (>= 0.22.0, < 0.23.0) GEM remote: https://rubygems.org/ @@ -140,8 +129,6 @@ GEM nio4r (2.7.4) nokogiri (1.16.7-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.7-x64-mingw-ucrt) - racc (~> 1.4) nokogiri (1.16.7-x86_64-darwin) racc (~> 1.4) nokogiri (1.16.7-x86_64-linux) @@ -225,6 +212,11 @@ GEM rubocop (~> 1.51) rubocop-sorbet (0.8.7) rubocop (>= 1) + ruby-lsp (0.22.0) + language_server-protocol (~> 3.17.0) + prism (>= 1.2, < 2.0) + rbs (>= 3, < 4) + sorbet-runtime (>= 0.5.10782) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) securerandom (0.3.1) @@ -242,7 +234,6 @@ GEM sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) sqlite3 (2.1.0-arm64-darwin) - sqlite3 (2.1.0-x64-mingw-ucrt) sqlite3 (2.1.0-x86_64-darwin) sqlite3 (2.1.0-x86_64-linux-gnu) stringio (3.1.2) @@ -275,7 +266,6 @@ GEM PLATFORMS arm64-darwin - x64-mingw-ucrt x86_64-darwin x86_64-linux @@ -289,7 +279,6 @@ DEPENDENCIES rubocop-rake (~> 0.6.0) rubocop-shopify (~> 2.15) rubocop-sorbet (~> 0.8) - ruby-lsp! ruby-lsp-rails! sorbet-static-and-runtime sqlite3 diff --git a/lib/ruby_lsp/ruby_lsp_rails/addon.rb b/lib/ruby_lsp/ruby_lsp_rails/addon.rb index d7b6461e..3fce20b0 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/addon.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/addon.rb @@ -56,7 +56,6 @@ def activate(global_state, outgoing_queue) @outgoing_queue << Notification.window_log_message("Activating Ruby LSP Rails add-on v#{VERSION}") register_additional_file_watchers(global_state: global_state, outgoing_queue: outgoing_queue) - @global_state.index.register_enhancement(IndexingEnhancement.new(@global_state.index)) # Start booting the real client in a background thread. Until this completes, the client will be a NullClient @client_mutex.unlock diff --git a/lib/ruby_lsp/ruby_lsp_rails/indexing_enhancement.rb b/lib/ruby_lsp/ruby_lsp_rails/indexing_enhancement.rb index d0aca528..b312807a 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/indexing_enhancement.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/indexing_enhancement.rb @@ -6,27 +6,27 @@ module Rails class IndexingEnhancement < RubyIndexer::Enhancement extend T::Sig + sig { params(listener: RubyIndexer::DeclarationListener).void } + def initialize(listener) + super + # We need this to prevent Sorbet from complaining that @listener is undeclared + @listener = listener + end + sig do override.params( - owner: T.nilable(RubyIndexer::Entry::Namespace), - node: Prism::CallNode, - file_path: String, - code_units_cache: T.any( - T.proc.params(arg0: Integer).returns(Integer), - Prism::CodeUnitsCache, - ), + call_node: Prism::CallNode, ).void end - def on_call_node_enter(owner, node, file_path, code_units_cache) + def on_call_node_enter(call_node) + owner = @listener.current_owner return unless owner - name = node.name - - case name + case call_node.name when :extend - handle_concern_extend(owner, node) + handle_concern_extend(owner, call_node) when :has_one, :has_many, :belongs_to, :has_and_belongs_to_many - handle_association(owner, node, file_path, code_units_cache) + handle_association(owner, call_node) end end @@ -35,16 +35,11 @@ def on_call_node_enter(owner, node, file_path, code_units_cache) sig do params( owner: RubyIndexer::Entry::Namespace, - node: Prism::CallNode, - file_path: String, - code_units_cache: T.any( - T.proc.params(arg0: Integer).returns(Integer), - Prism::CodeUnitsCache, - ), + call_node: Prism::CallNode, ).void end - def handle_association(owner, node, file_path, code_units_cache) - arguments = node.arguments&.arguments + def handle_association(owner, call_node) + arguments = call_node.arguments&.arguments return unless arguments name_arg = arguments.first @@ -58,41 +53,22 @@ def handle_association(owner, node, file_path, code_units_cache) return unless name - loc = RubyIndexer::Location.from_prism_location(name_arg.location, code_units_cache) + loc = name_arg.location # Reader - @index.add(RubyIndexer::Entry::Method.new( - name, - file_path, - loc, - loc, - nil, - [RubyIndexer::Entry::Signature.new([])], - RubyIndexer::Entry::Visibility::PUBLIC, - owner, - )) + reader_signatures = [RubyIndexer::Entry::Signature.new([])] + @listener.add_method(name, loc, reader_signatures) # Writer - @index.add(RubyIndexer::Entry::Method.new( - "#{name}=", - file_path, - loc, - loc, - nil, - [RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: name.to_sym)])], - RubyIndexer::Entry::Visibility::PUBLIC, - owner, - )) + writer_signatures = [ + RubyIndexer::Entry::Signature.new([RubyIndexer::Entry::RequiredParameter.new(name: name.to_sym)]), + ] + @listener.add_method("#{name}=", loc, writer_signatures) end - sig do - params( - owner: RubyIndexer::Entry::Namespace, - node: Prism::CallNode, - ).void - end - def handle_concern_extend(owner, node) - arguments = node.arguments&.arguments + sig { params(owner: RubyIndexer::Entry::Namespace, call_node: Prism::CallNode).void } + def handle_concern_extend(owner, call_node) + arguments = call_node.arguments&.arguments return unless arguments arguments.each do |node| @@ -101,7 +77,7 @@ def handle_concern_extend(owner, node) module_name = node.full_name next unless module_name == "ActiveSupport::Concern" - @index.register_included_hook(owner.name) do |index, base| + @listener.register_included_hook do |index, base| class_methods_name = "#{owner.name}::ClassMethods" if index.indexed?(class_methods_name) diff --git a/ruby-lsp-rails.gemspec b/ruby-lsp-rails.gemspec index 827d0e90..98bcc8ae 100644 --- a/ruby-lsp-rails.gemspec +++ b/ruby-lsp-rails.gemspec @@ -24,5 +24,5 @@ Gem::Specification.new do |spec| Dir["lib/**/*", "LICENSE.txt", "Rakefile", "README.md"] end - spec.add_dependency("ruby-lsp", ">= 0.21.2", "< 0.22.0") + spec.add_dependency("ruby-lsp", ">= 0.22.0", "< 0.23.0") end diff --git a/sorbet/rbi/gems/ruby-lsp@0.21.4-bb3a5b25da4ba2931278fdeb1f0fbdf40b8545c3.rbi b/sorbet/rbi/gems/ruby-lsp@0.22.0.rbi similarity index 98% rename from sorbet/rbi/gems/ruby-lsp@0.21.4-bb3a5b25da4ba2931278fdeb1f0fbdf40b8545c3.rbi rename to sorbet/rbi/gems/ruby-lsp@0.22.0.rbi index 905fc264..b6ab9075 100644 --- a/sorbet/rbi/gems/ruby-lsp@0.21.4-bb3a5b25da4ba2931278fdeb1f0fbdf40b8545c3.rbi +++ b/sorbet/rbi/gems/ruby-lsp@0.22.0.rbi @@ -73,7 +73,7 @@ class RubyIndexer::DeclarationListener end def initialize(index, dispatcher, parse_result, file_path, collect_comments: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#489 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#490 sig do params( name_or_nesting: T.any(::String, T::Array[::String]), @@ -85,7 +85,7 @@ class RubyIndexer::DeclarationListener end def add_class(name_or_nesting, full_location, name_location, parent_class_name: T.unsafe(nil), comments: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#442 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#443 sig do params( name: ::String, @@ -97,7 +97,7 @@ class RubyIndexer::DeclarationListener end def add_method(name, node_location, signatures, visibility: T.unsafe(nil), comments: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#465 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#466 sig do params( name: ::String, @@ -108,7 +108,7 @@ class RubyIndexer::DeclarationListener end def add_module(name, full_location, name_location, comments: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#521 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#522 sig { returns(T.nilable(::RubyIndexer::Entry::Namespace)) } def current_owner; end @@ -116,141 +116,141 @@ class RubyIndexer::DeclarationListener sig { returns(T::Array[::String]) } def indexing_errors; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#418 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#419 sig { params(node: ::Prism::AliasMethodNode).void } def on_alias_method_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#260 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#261 sig { params(node: ::Prism::CallNode).void } def on_call_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#296 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#297 sig { params(node: ::Prism::CallNode).void } def on_call_node_leave(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#86 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#87 sig { params(node: ::Prism::ClassNode).void } def on_class_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#118 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#119 sig { params(node: ::Prism::ClassNode).void } def on_class_node_leave(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#248 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#249 sig { params(node: ::Prism::ConstantAndWriteNode).void } def on_constant_and_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#254 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#255 sig { params(node: ::Prism::ConstantOperatorWriteNode).void } def on_constant_operator_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#242 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#243 sig { params(node: ::Prism::ConstantOrWriteNode).void } def on_constant_or_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#226 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#227 sig { params(node: ::Prism::ConstantPathAndWriteNode).void } def on_constant_path_and_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#216 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#217 sig { params(node: ::Prism::ConstantPathOperatorWriteNode).void } def on_constant_path_operator_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#206 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#207 sig { params(node: ::Prism::ConstantPathOrWriteNode).void } def on_constant_path_or_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#196 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#197 sig { params(node: ::Prism::ConstantPathWriteNode).void } def on_constant_path_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#236 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#237 sig { params(node: ::Prism::ConstantWriteNode).void } def on_constant_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#317 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#318 sig { params(node: ::Prism::DefNode).void } def on_def_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#358 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#359 sig { params(node: ::Prism::DefNode).void } def on_def_node_leave(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#368 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#369 sig { params(node: ::Prism::GlobalVariableAndWriteNode).void } def on_global_variable_and_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#373 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#374 sig { params(node: ::Prism::GlobalVariableOperatorWriteNode).void } def on_global_variable_operator_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#378 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#379 sig { params(node: ::Prism::GlobalVariableOrWriteNode).void } def on_global_variable_or_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#383 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#384 sig { params(node: ::Prism::GlobalVariableTargetNode).void } def on_global_variable_target_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#388 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#389 sig { params(node: ::Prism::GlobalVariableWriteNode).void } def on_global_variable_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#398 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#399 sig { params(node: ::Prism::InstanceVariableAndWriteNode).void } def on_instance_variable_and_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#403 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#404 sig { params(node: ::Prism::InstanceVariableOperatorWriteNode).void } def on_instance_variable_operator_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#408 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#409 sig { params(node: ::Prism::InstanceVariableOrWriteNode).void } def on_instance_variable_or_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#413 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#414 sig { params(node: ::Prism::InstanceVariableTargetNode).void } def on_instance_variable_target_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#393 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#394 sig { params(node: ::Prism::InstanceVariableWriteNode).void } def on_instance_variable_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#123 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#124 sig { params(node: ::Prism::ModuleNode).void } def on_module_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#129 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#130 sig { params(node: ::Prism::ModuleNode).void } def on_module_node_leave(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#176 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#177 sig { params(node: ::Prism::MultiWriteNode).void } def on_multi_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#134 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#135 sig { params(node: ::Prism::SingletonClassNode).void } def on_singleton_class_node_enter(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#171 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#172 sig { params(node: ::Prism::SingletonClassNode).void } def on_singleton_class_node_leave(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#514 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#515 sig { void } def pop_namespace_stack; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#504 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#505 sig { params(block: T.proc.params(index: ::RubyIndexer::Index, base: ::RubyIndexer::Entry::Namespace).void).void } def register_included_hook(&block); end private - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#960 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#971 sig { params(name: ::String).returns(T::Array[::String]) } def actual_nesting(name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#666 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#667 sig do params( node: T.any(::Prism::ConstantAndWriteNode, ::Prism::ConstantOperatorWriteNode, ::Prism::ConstantOrWriteNode, ::Prism::ConstantPathAndWriteNode, ::Prism::ConstantPathOperatorWriteNode, ::Prism::ConstantPathOrWriteNode, ::Prism::ConstantPathTargetNode, ::Prism::ConstantPathWriteNode, ::Prism::ConstantTargetNode, ::Prism::ConstantWriteNode), @@ -260,31 +260,35 @@ class RubyIndexer::DeclarationListener end def add_constant(node, name, value = T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#974 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#985 sig { params(short_name: ::String, entry: ::RubyIndexer::Entry::Namespace).void } def advance_namespace_stack(short_name, entry); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#717 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#718 sig { params(node: ::Prism::Node).returns(T.nilable(::String)) } def collect_comments(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#868 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#746 + sig { params(line: ::Integer).returns(T::Boolean) } + def comment_exists_at?(line); end + + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#879 sig { returns(::RubyIndexer::Entry::Visibility) } def current_visibility; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#746 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#751 sig { params(name: ::String).returns(::String) } def fully_qualify_name(name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#610 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#611 sig { params(node: ::Prism::CallNode).void } def handle_alias_method(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#755 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#760 sig { params(node: ::Prism::CallNode, reader: T::Boolean, writer: T::Boolean).void } def handle_attribute(node, reader:, writer:); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#539 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#540 sig do params( node: T.any(::Prism::GlobalVariableAndWriteNode, ::Prism::GlobalVariableOperatorWriteNode, ::Prism::GlobalVariableOrWriteNode, ::Prism::GlobalVariableTargetNode, ::Prism::GlobalVariableWriteNode), @@ -293,7 +297,7 @@ class RubyIndexer::DeclarationListener end def handle_global_variable(node, loc); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#563 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#564 sig do params( node: T.any(::Prism::InstanceVariableAndWriteNode, ::Prism::InstanceVariableOperatorWriteNode, ::Prism::InstanceVariableOrWriteNode, ::Prism::InstanceVariableTargetNode, ::Prism::InstanceVariableWriteNode), @@ -302,19 +306,19 @@ class RubyIndexer::DeclarationListener end def handle_instance_variable(node, loc); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#826 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#837 sig { params(node: ::Prism::CallNode).void } def handle_module_function(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#798 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#803 sig { params(node: ::Prism::CallNode, operation: ::Symbol).void } def handle_module_operation(node, operation); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#585 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#586 sig { params(node: ::Prism::CallNode).void } def handle_private_constant(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#873 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#884 sig do params( parameters_node: T.nilable(::Prism::ParametersNode) @@ -322,7 +326,7 @@ class RubyIndexer::DeclarationListener end def list_params(parameters_node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#935 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#946 sig { params(node: T.nilable(::Prism::Node)).returns(T.nilable(::Symbol)) } def parameter_name(node); end end @@ -2378,17 +2382,17 @@ class RubyLsp::GlobalState sig { void } def initialize; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#70 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#69 sig { returns(T.nilable(::RubyLsp::Requests::Support::Formatter)) } def active_formatter; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#75 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#74 sig { returns(T::Array[::RubyLsp::Requests::Support::Formatter]) } def active_linters; end # Applies the options provided by the editor and returns an array of notifications to send back to the client # - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#81 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#80 sig { params(options: T::Hash[::Symbol, T.untyped]).returns(T::Array[::RubyLsp::Notification]) } def apply_options(options); end @@ -2396,7 +2400,7 @@ class RubyLsp::GlobalState sig { returns(::RubyLsp::ClientCapabilities) } def client_capabilities; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#150 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#148 sig { params(flag: ::Symbol).returns(T.nilable(T::Boolean)) } def enabled_feature?(flag); end @@ -2404,14 +2408,10 @@ class RubyLsp::GlobalState sig { returns(::Encoding) } def encoding; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#160 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#158 sig { returns(::String) } def encoding_name; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#24 - sig { returns(T::Boolean) } - def experimental_features; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#12 sig { returns(::String) } def formatter; end @@ -2429,15 +2429,15 @@ class RubyLsp::GlobalState sig { returns(::RubyIndexer::Index) } def index; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#65 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#64 sig { params(identifier: ::String, instance: ::RubyLsp::Requests::Support::Formatter).void } def register_formatter(identifier, instance); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#60 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#59 sig { params(addon_name: ::String).returns(T.nilable(T::Hash[::Symbol, T.untyped])) } def settings_for_addon(addon_name); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#172 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#170 sig { returns(T::Boolean) } def supports_watching_files; end @@ -2445,57 +2445,56 @@ class RubyLsp::GlobalState sig { returns(::String) } def test_library; end - # @return [Boolean] - # # source://ruby-lsp/lib/ruby_lsp/global_state.rb#24 + sig { returns(T::Boolean) } def top_level_bundle; end # source://ruby-lsp/lib/ruby_lsp/global_state.rb#27 sig { returns(::RubyLsp::TypeInferrer) } def type_inferrer; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#155 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#153 sig { returns(::String) } def workspace_path; end private - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#235 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#233 sig { returns(T::Boolean) } def bin_rails_present; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#179 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#177 sig { params(direct_dependencies: T::Array[::String], all_dependencies: T::Array[::String]).returns(::String) } def detect_formatter(direct_dependencies, all_dependencies); end # Try to detect if there are linters in the project's dependencies. For auto-detection, we always only consider a # single linter. To have multiple linters running, the user must configure them manually # - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#195 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#193 sig { params(dependencies: T::Array[::String], all_dependencies: T::Array[::String]).returns(T::Array[::String]) } def detect_linters(dependencies, all_dependencies); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#206 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#204 sig { params(dependencies: T::Array[::String]).returns(::String) } def detect_test_library(dependencies); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#226 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#224 sig { params(dependencies: T::Array[::String]).returns(T::Boolean) } def detect_typechecker(dependencies); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#240 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#238 sig { returns(T::Boolean) } def dot_rubocop_yml_present; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#262 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#260 sig { returns(T::Array[::String]) } def gather_direct_and_indirect_dependencies; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#245 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#243 sig { returns(T::Array[::String]) } def gather_direct_dependencies; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#255 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#253 sig { returns(T::Array[::String]) } def gemspec_dependencies; end end @@ -5696,35 +5695,35 @@ class RubyLsp::Server < ::RubyLsp::BaseServer private - # source://ruby-lsp/lib/ruby_lsp/server.rb#1119 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1127 sig { params(id: ::String, title: ::String, percentage: ::Integer).void } def begin_progress(id, title, percentage: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1149 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1157 sig { void } def check_formatter_is_available; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#805 + # source://ruby-lsp/lib/ruby_lsp/server.rb#813 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def code_action_resolve(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1139 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1147 sig { params(id: ::String).void } def end_progress(id); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1087 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1095 sig { void } def perform_initial_indexing; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1168 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1176 sig { params(indexing_options: T.nilable(T::Hash[::Symbol, T.untyped])).void } def process_indexing_configuration(indexing_options); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1132 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1140 sig { params(id: ::String, percentage: ::Integer).void } def progress(id, percentage); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#448 + # source://ruby-lsp/lib/ruby_lsp/server.rb#456 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def run_combined_requests(message); end @@ -5732,19 +5731,19 @@ class RubyLsp::Server < ::RubyLsp::BaseServer sig { params(message: T::Hash[::Symbol, T.untyped]).void } def run_initialize(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#329 + # source://ruby-lsp/lib/ruby_lsp/server.rb#337 sig { void } def run_initialized; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1082 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1090 sig { override.void } def shutdown; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#741 + # source://ruby-lsp/lib/ruby_lsp/server.rb#749 sig { params(document: RubyLsp::Document[T.untyped]).returns(::RubyLsp::RubyDocument::SorbetLevel) } def sorbet_level(document); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#783 + # source://ruby-lsp/lib/ruby_lsp/server.rb#791 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_code_action(message); end @@ -5754,35 +5753,35 @@ class RubyLsp::Server < ::RubyLsp::BaseServer # source://sorbet-runtime/0.5.11635lib/types/private/methods/_methods.rb#257 def text_document_code_lens(*args, **_arg1, &blk); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#870 + # source://ruby-lsp/lib/ruby_lsp/server.rb#878 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_completion(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#895 + # source://ruby-lsp/lib/ruby_lsp/server.rb#903 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_completion_item_resolve(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#940 + # source://ruby-lsp/lib/ruby_lsp/server.rb#948 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_definition(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#830 + # source://ruby-lsp/lib/ruby_lsp/server.rb#838 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_diagnostic(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#412 + # source://ruby-lsp/lib/ruby_lsp/server.rb#420 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_did_change(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#396 + # source://ruby-lsp/lib/ruby_lsp/server.rb#404 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_did_close(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#356 + # source://ruby-lsp/lib/ruby_lsp/server.rb#364 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_did_open(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#639 + # source://ruby-lsp/lib/ruby_lsp/server.rb#647 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_document_highlight(message); end @@ -5804,83 +5803,83 @@ class RubyLsp::Server < ::RubyLsp::BaseServer # source://sorbet-runtime/0.5.11635lib/types/private/methods/_methods.rb#257 def text_document_folding_range(*args, **_arg1, &blk); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#595 + # source://ruby-lsp/lib/ruby_lsp/server.rb#603 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_formatting(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#678 + # source://ruby-lsp/lib/ruby_lsp/server.rb#686 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_hover(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#749 + # source://ruby-lsp/lib/ruby_lsp/server.rb#757 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_inlay_hint(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#655 + # source://ruby-lsp/lib/ruby_lsp/server.rb#663 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_on_type_formatting(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1024 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1032 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_prepare_type_hierarchy(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#567 + # source://ruby-lsp/lib/ruby_lsp/server.rb#575 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_range_formatting(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#723 + # source://ruby-lsp/lib/ruby_lsp/server.rb#731 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_references(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#703 + # source://ruby-lsp/lib/ruby_lsp/server.rb#711 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_rename(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#422 + # source://ruby-lsp/lib/ruby_lsp/server.rb#430 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_selection_range(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#513 + # source://ruby-lsp/lib/ruby_lsp/server.rb#521 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_semantic_tokens_delta(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#492 + # source://ruby-lsp/lib/ruby_lsp/server.rb#500 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_semantic_tokens_full(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#538 + # source://ruby-lsp/lib/ruby_lsp/server.rb#546 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_semantic_tokens_range(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1005 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1013 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_show_syntax_tree(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#914 + # source://ruby-lsp/lib/ruby_lsp/server.rb#922 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_signature_help(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1052 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1060 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def type_hierarchy_subtypes(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1043 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1051 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def type_hierarchy_supertypes(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1209 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1217 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def window_show_message_request(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#1059 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1067 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def workspace_dependencies(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#965 + # source://ruby-lsp/lib/ruby_lsp/server.rb#973 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def workspace_did_change_watched_files(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#992 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1000 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def workspace_symbol(message); end end diff --git a/test/dummy/app/models/concerns/verifiable.rb b/test/dummy/app/models/concerns/verifiable.rb new file mode 100644 index 00000000..4f01a0e6 --- /dev/null +++ b/test/dummy/app/models/concerns/verifiable.rb @@ -0,0 +1,16 @@ +# frozen_string_literal: true + +module Verifiable + extend ActiveSupport::Concern + + # checks if a user is verified + def verified? + true + end + + module ClassMethods + def all_verified + all.select(&:verified?) + end + end +end diff --git a/test/dummy/app/models/user.rb b/test/dummy/app/models/user.rb index f3b57411..c696c86d 100644 --- a/test/dummy/app/models/user.rb +++ b/test/dummy/app/models/user.rb @@ -9,6 +9,8 @@ class User < ApplicationRecord attr_readonly :last_name + include Verifiable # an ActiveSupport::Concern + private def foo diff --git a/test/ruby_lsp_rails/indexing_enhancement_test.rb b/test/ruby_lsp_rails/indexing_enhancement_test.rb index b6c7b66b..ba61730a 100644 --- a/test/ruby_lsp_rails/indexing_enhancement_test.rb +++ b/test/ruby_lsp_rails/indexing_enhancement_test.rb @@ -12,8 +12,6 @@ class << self def populated_index @index ||= begin index = RubyIndexer::Index.new - indexing_enhancement = IndexingEnhancement.new(index) - index.register_enhancement(indexing_enhancement) index.index_all index end