diff --git a/Gemfile b/Gemfile index 47ef288e..f09f81bb 100644 --- a/Gemfile +++ b/Gemfile @@ -25,3 +25,5 @@ platforms :mingw, :x64_mingw, :mswin, :jruby do gem "tzinfo" gem "tzinfo-data" end + +gem "ruby-lsp", github: "Shopify/ruby-lsp", branch: "add-on-client-server-framework" diff --git a/Gemfile.lock b/Gemfile.lock index 24a8fbe9..be67d1d2 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -6,6 +6,17 @@ GIT rdoc (6.6.3.1) psych (>= 4.0.0) +GIT + remote: https://github.com/Shopify/ruby-lsp.git + revision: 6484963320dc6d225d2572adcb0c3aadc7598d40 + branch: add-on-client-server-framework + specs: + ruby-lsp (0.17.17) + language_server-protocol (~> 3.17.0) + prism (>= 0.29.0, < 0.31) + rbs (>= 3, < 4) + sorbet-runtime (>= 0.5.10782) + PATH remote: . specs: @@ -146,8 +157,6 @@ GEM nio4r (2.7.3) nokogiri (1.16.5-arm64-darwin) racc (~> 1.4) - nokogiri (1.16.5-x64-mingw-ucrt) - racc (~> 1.4) nokogiri (1.16.5-x86_64-darwin) racc (~> 1.4) nokogiri (1.16.5-x86_64-linux) @@ -234,11 +243,6 @@ GEM rubocop (~> 1.51) rubocop-sorbet (0.8.3) rubocop (>= 0.90.0) - ruby-lsp (0.17.12) - language_server-protocol (~> 3.17.0) - prism (>= 0.29.0, < 0.31) - rbs (>= 3, < 4) - sorbet-runtime (>= 0.5.10782) ruby-progressbar (1.13.0) ruby2_keywords (0.0.5) sorbet (0.5.11406) @@ -255,7 +259,6 @@ GEM sorbet-static-and-runtime (>= 0.5.10187) thor (>= 0.19.2) sqlite3 (1.7.3-arm64-darwin) - sqlite3 (1.7.3-x64-mingw-ucrt) sqlite3 (1.7.3-x86_64-darwin) sqlite3 (1.7.3-x86_64-linux) stringio (3.1.0) @@ -273,8 +276,6 @@ GEM timeout (0.4.1) tzinfo (2.0.6) concurrent-ruby (~> 1.0) - tzinfo-data (1.2024.1) - tzinfo (>= 1.0.0) unicode-display_width (2.5.0) webmock (3.23.1) addressable (>= 2.8.0) @@ -292,7 +293,6 @@ GEM PLATFORMS arm64-darwin - x64-mingw-ucrt x86_64-darwin x86_64-linux @@ -307,6 +307,7 @@ DEPENDENCIES rubocop-rake (~> 0.6.0) rubocop-shopify (~> 2.15) rubocop-sorbet (~> 0.8) + ruby-lsp! ruby-lsp-rails! sorbet-static-and-runtime sqlite3 (< 2) diff --git a/lib/ruby_lsp/ruby_lsp_rails/addon.rb b/lib/ruby_lsp/ruby_lsp_rails/addon.rb index 7358aa56..2fc33cb4 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/addon.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/addon.rb @@ -32,9 +32,9 @@ def initialize sig { override.params(global_state: GlobalState, message_queue: Thread::Queue).void } def activate(global_state, message_queue) @global_state = T.let(global_state, T.nilable(RubyLsp::GlobalState)) - $stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}") + $stderr.puts("Activating Ruby LSP Rails addon v#{VERSION}") unless ENV["RAILS_ENV"] == "test" # Start booting the real client in a background thread. Until this completes, the client will be a NullClient - Thread.new { @client = RunnerClient.create_client } + Thread.new { @client = RunnerClient.create_client(self) } register_additional_file_watchers(global_state: global_state, message_queue: message_queue) T.must(@global_state).index.register_enhancement(IndexingEnhancement.new) diff --git a/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb b/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb index 8ff76363..0ab317d2 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/runner_client.rb @@ -3,17 +3,20 @@ require "json" require "open3" +require "ruby_lsp/addon/process_client" module RubyLsp module Rails - class RunnerClient + class RunnerClient < RubyLsp::Addon::ProcessClient + COMMAND = T.let(["bundle", "exec", "rails", "runner", "#{__dir__}/server.rb", "start"].join(" "), String) + class << self extend T::Sig - sig { returns(RunnerClient) } - def create_client + sig { params(addon: RubyLsp::Addon).returns(RunnerClient) } + def create_client(addon) if File.exist?("bin/rails") - new + new(addon, COMMAND) else $stderr.puts(<<~MSG) Ruby LSP Rails failed to locate bin/rails in the current directory: #{Dir.pwd}" @@ -28,76 +31,44 @@ def create_client end end - class InitializationError < StandardError; end - class IncompleteMessageError < StandardError; end - class EmptyMessageError < StandardError; end - - MAX_RETRIES = 5 - extend T::Sig sig { returns(String) } - attr_reader :rails_root - - sig { void } - def initialize - @mutex = T.let(Mutex.new, Mutex) - # Spring needs a Process session ID. It uses this ID to "attach" itself to the parent process, so that when the - # parent ends, the spring process ends as well. If this is not set, Spring will throw an error while trying to - # set its own session ID - begin - Process.setpgrp - Process.setsid - rescue Errno::EPERM - # If we can't set the session ID, continue - rescue NotImplementedError - # setpgrp() may be unimplemented on some platform - # https://github.com/Shopify/ruby-lsp-rails/issues/348 - end - - stdin, stdout, stderr, wait_thread = Bundler.with_original_env do - Open3.popen3("bundle", "exec", "rails", "runner", "#{__dir__}/server.rb", "start") - end - - @stdin = T.let(stdin, IO) - @stdout = T.let(stdout, IO) - @stderr = T.let(stderr, IO) - @wait_thread = T.let(wait_thread, Process::Waiter) - @stdin.binmode # for Windows compatibility - @stdout.binmode # for Windows compatibility - - $stderr.puts("Ruby LSP Rails booting server") - count = 0 + def rails_root + T.must(@rails_root) + end - begin - count += 1 - initialize_response = T.must(read_response) - @rails_root = T.let(initialize_response[:root], String) - rescue EmptyMessageError - $stderr.puts("Ruby LSP Rails is retrying initialize (#{count})") - retry if count < MAX_RETRIES + sig { params(message: String).void } + def log_output(message) + # We don't want to log output in tests + unless ENV["RAILS_ENV"] == "test" + super end + end - $stderr.puts("Finished booting Ruby LSP Rails server") + sig { override.params(response: T::Hash[Symbol, T.untyped]).void } + def handle_initialize_response(response) + @rails_root = T.let(response[:root], T.nilable(String)) + end + sig { override.void } + def register_exit_handler unless ENV["RAILS_ENV"] == "test" at_exit do - if @wait_thread.alive? - $stderr.puts("Ruby LSP Rails is force killing the server") + if wait_thread.alive? + log_output("force killing the server") sleep(0.5) # give the server a bit of time if we already issued a shutdown notification force_kill end end end - rescue Errno::EPIPE, IncompleteMessageError - raise InitializationError, @stderr.read end sig { params(name: String).returns(T.nilable(T::Hash[Symbol, T.untyped])) } def model(name) make_request("model", name: name) rescue IncompleteMessageError - $stderr.puts("Ruby LSP Rails failed to get model information: #{@stderr.read}") + log_output("failed to get model information: #{stderr.read}") nil end @@ -114,14 +85,15 @@ def association_target_location(model_name:, association_name:) association_name: association_name, ) rescue => e - $stderr.puts("Ruby LSP Rails failed with #{e.message}: #{@stderr.read}") + log_output("failed with #{e.message}: #{stderr.read}") + nil end sig { params(name: String).returns(T.nilable(T::Hash[Symbol, T.untyped])) } def route_location(name) make_request("route_location", name: name) rescue IncompleteMessageError - $stderr.puts("Ruby LSP Rails failed to get route location: #{@stderr.read}") + log_output("failed to get route location: #{stderr.read}") nil end @@ -129,102 +101,31 @@ def route_location(name) def route(controller:, action:) make_request("route_info", controller: controller, action: action) rescue IncompleteMessageError - $stderr.puts("Ruby LSP Rails failed to get route information: #{@stderr.read}") + log_output("failed to get route information: #{stderr.read}") nil end sig { void } def trigger_reload - $stderr.puts("Reloading Rails application") + log_output("triggering reload") send_notification("reload") rescue IncompleteMessageError - $stderr.puts("Ruby LSP Rails failed to trigger reload") - nil - end - - sig { void } - def shutdown - $stderr.puts("Ruby LSP Rails shutting down server") - send_message("shutdown") - sleep(0.5) # give the server a bit of time to shutdown - [@stdin, @stdout, @stderr].each(&:close) - rescue IOError - # The server connection may have died - force_kill - end - - sig { returns(T::Boolean) } - def stopped? - [@stdin, @stdout, @stderr].all?(&:closed?) && !@wait_thread.alive? - end - - private - - sig do - params( - request: String, - params: T.nilable(T::Hash[Symbol, T.untyped]), - ).returns(T.nilable(T::Hash[Symbol, T.untyped])) - end - def make_request(request, params = nil) - send_message(request, params) - read_response - end - - sig { overridable.params(request: String, params: T.nilable(T::Hash[Symbol, T.untyped])).void } - def send_message(request, params = nil) - message = { method: request } - message[:params] = params if params - json = message.to_json - - @mutex.synchronize do - @stdin.write("Content-Length: #{json.length}\r\n\r\n", json) - end - rescue Errno::EPIPE - # The server connection died - end - - # Notifications are like messages, but one-way, with no response sent back. - sig { params(request: String, params: T.nilable(T::Hash[Symbol, T.untyped])).void } - def send_notification(request, params = nil) = send_message(request, params) - - sig { overridable.returns(T.nilable(T::Hash[Symbol, T.untyped])) } - def read_response - raw_response = @mutex.synchronize do - headers = @stdout.gets("\r\n\r\n") - raise IncompleteMessageError unless headers - - content_length = headers[/Content-Length: (\d+)/i, 1].to_i - raise EmptyMessageError if content_length.zero? - - @stdout.read(content_length) - end - - response = JSON.parse(T.must(raw_response), symbolize_names: true) - - if response[:error] - $stderr.puts("Ruby LSP Rails error: " + response[:error]) - return - end - - response.fetch(:result) - rescue Errno::EPIPE - # The server connection died + log_output("failed to trigger reload") nil end - - sig { void } - def force_kill - # Windows does not support the `TERM` signal, so we're forced to use `KILL` here - Process.kill(T.must(Signal.list["KILL"]), @wait_thread.pid) - end end class NullClient < RunnerClient extend T::Sig sig { void } - def initialize # rubocop:disable Lint/MissingSuper + def initialize + # no-op + end + + sig { override.params(response: T::Hash[Symbol, T.untyped]).void } + def handle_initialize_response(response) + # no-op end sig { override.void } diff --git a/lib/ruby_lsp/ruby_lsp_rails/server.rb b/lib/ruby_lsp/ruby_lsp_rails/server.rb index 9ce05c0f..c18cf2f3 100644 --- a/lib/ruby_lsp/ruby_lsp_rails/server.rb +++ b/lib/ruby_lsp/ruby_lsp_rails/server.rb @@ -1,45 +1,31 @@ -# typed: false +# typed: true # frozen_string_literal: true require "json" +require "ruby_lsp/addon/process_server" # NOTE: We should avoid printing to stderr since it causes problems. We never read the standard error pipe from the # client, so it will become full and eventually hang or crash. Instead, return a response with an `error` key. module RubyLsp module Rails - class Server - VOID = Object.new - - def initialize - $stdin.sync = true - $stdout.sync = true - $stdin.binmode - $stdout.binmode - @running = true - end + class Server < RubyLsp::Addon::ProcessServer + extend T::Sig + sig { void } def start # Load routes if they haven't been loaded yet (see https://github.com/rails/rails/pull/51614). routes_reloader = ::Rails.application.routes_reloader routes_reloader.execute_unless_loaded if routes_reloader&.respond_to?(:execute_unless_loaded) + super + end - initialize_result = { result: { message: "ok", root: ::Rails.root.to_s } }.to_json - $stdout.write("Content-Length: #{initialize_result.length}\r\n\r\n#{initialize_result}") - - while @running - headers = $stdin.gets("\r\n\r\n") - json = $stdin.read(headers[/Content-Length: (\d+)/i, 1].to_i) - - request = JSON.parse(json, symbolize_names: true) - response = execute(request.fetch(:method), request[:params]) - next if response == VOID - - json_response = response.to_json - $stdout.write("Content-Length: #{json_response.length}\r\n\r\n#{json_response}") - end + sig { override.returns(String) } + def generate_initialize_response + { result: { message: "ok", root: ::Rails.root.to_s } }.to_json end + sig { override.params(request: String, params: T.untyped).returns(T.nilable(T::Hash[Symbol, T.untyped])) } def execute(request, params) case request when "shutdown" @@ -72,7 +58,7 @@ def resolve_route_info(requirements) # In Rails 7.2 we can use `from_requirements, otherwise we fall back to a private API route = if ::Rails.application.routes.respond_to?(:from_requirements) - ::Rails.application.routes.from_requirements(requirements) + T.unsafe(::Rails.application.routes).from_requirements(requirements) else ::Rails.application.routes.routes.find { |route| route.requirements == requirements } end @@ -154,7 +140,7 @@ def resolve_association_target(params) association_klass = const.reflect_on_association(params[:association_name].intern).klass - source_location = Object.const_source_location(association_klass.to_s) + source_location = T.must(Object.const_source_location(association_klass.to_s)) { result: { @@ -173,7 +159,7 @@ def active_record_model?(const) defined?(ActiveRecord) && const.is_a?(Class) && ActiveRecord::Base > const && # We do this 'backwards' in case the class overwrites `<` - !const.abstract_class? + !T.unsafe(const).abstract_class? ) end end diff --git a/sorbet/rbi/gems/ruby-lsp@0.17.12.rbi b/sorbet/rbi/gems/ruby-lsp@0.17.17-6484963320dc6d225d2572adcb0c3aadc7598d40.rbi similarity index 90% rename from sorbet/rbi/gems/ruby-lsp@0.17.12.rbi rename to sorbet/rbi/gems/ruby-lsp@0.17.17-6484963320dc6d225d2572adcb0c3aadc7598d40.rbi index 73474e90..2173f9c8 100644 --- a/sorbet/rbi/gems/ruby-lsp@0.17.12.rbi +++ b/sorbet/rbi/gems/ruby-lsp@0.17.17-6484963320dc6d225d2572adcb0c3aadc7598d40.rbi @@ -5,41 +5,39 @@ # Please instead update this file by running `bin/tapioca gem ruby-lsp`. # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/indexable_path.rb#4 -module RubyIndexer - class << self - # source://ruby-lsp/lib/ruby_indexer/ruby_indexer.rb#24 - sig { returns(::RubyIndexer::Configuration) } - def configuration; end - end -end +module RubyIndexer; end # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#5 class RubyIndexer::Configuration - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#20 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#23 sig { void } def initialize; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#149 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#168 sig { params(config: T::Hash[::String, T.untyped]).void } def apply_config(config); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#47 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#56 sig { returns(T::Array[::RubyIndexer::IndexablePath]) } def indexables; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#144 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#163 sig { returns(::Regexp) } def magic_comment_regex; end + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#20 + sig { params(workspace_path: ::String).void } + def workspace_path=(workspace_path); end + private - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#177 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#196 sig { returns(T::Array[::String]) } def initial_excluded_gems; end # @raise [ArgumentError] # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#162 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/configuration.rb#181 sig { params(config: T::Hash[::String, T.untyped]).void } def validate_config!(config); end end @@ -65,15 +63,15 @@ class RubyIndexer::DeclarationListener sig { returns(T::Array[::String]) } def indexing_errors; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#391 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#393 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#270 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#272 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#302 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#304 sig { params(node: ::Prism::CallNode).void } def on_call_node_leave(node); end @@ -85,63 +83,63 @@ class RubyIndexer::DeclarationListener 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#258 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#260 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#264 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#266 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#252 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#254 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#236 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#238 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#226 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#228 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#216 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#218 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#206 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#208 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#246 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#248 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#315 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#317 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#356 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#358 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#371 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#373 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#376 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#378 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#381 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#383 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#386 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#388 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#366 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#368 sig { params(node: ::Prism::InstanceVariableWriteNode).void } def on_instance_variable_write_node_enter(node); end @@ -153,7 +151,7 @@ class RubyIndexer::DeclarationListener 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#186 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#188 sig { params(node: ::Prism::MultiWriteNode).void } def on_multi_write_node_enter(node); end @@ -161,17 +159,17 @@ class RubyIndexer::DeclarationListener 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#179 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#181 sig { params(node: ::Prism::SingletonClassNode).void } def on_singleton_class_node_leave(node); end private - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#730 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#732 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#517 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#519 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), @@ -181,27 +179,27 @@ 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#542 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#544 sig { params(node: ::Prism::Node).returns(T::Array[::String]) } def collect_comments(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#641 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#643 sig { returns(::RubyIndexer::Entry::Visibility) } def current_visibility; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#568 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#570 sig { params(name: ::String).returns(::String) } def fully_qualify_name(name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#461 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#463 sig { params(node: ::Prism::CallNode).void } def handle_alias_method(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#577 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#579 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#420 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#422 sig do params( node: T.any(::Prism::InstanceVariableAndWriteNode, ::Prism::InstanceVariableOperatorWriteNode, ::Prism::InstanceVariableOrWriteNode, ::Prism::InstanceVariableTargetNode, ::Prism::InstanceVariableWriteNode), @@ -210,15 +208,15 @@ class RubyIndexer::DeclarationListener end def handle_instance_variable(node, loc); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#613 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#615 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#436 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#438 sig { params(node: ::Prism::CallNode).void } def handle_private_constant(node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#646 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#648 sig do params( parameters_node: T.nilable(::Prism::ParametersNode) @@ -226,7 +224,7 @@ class RubyIndexer::DeclarationListener end def list_params(parameters_node); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#705 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/declaration_listener.rb#707 sig { params(node: T.nilable(::Prism::Node)).returns(T.nilable(::Symbol)) } def parameter_name(node); end end @@ -778,34 +776,38 @@ end # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#5 class RubyIndexer::Index - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#15 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#18 sig { void } def initialize; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#99 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#104 sig { params(fully_qualified_name: ::String).returns(T.nilable(T::Array[::RubyIndexer::Entry])) } def [](fully_qualified_name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#90 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#95 sig { params(entry: ::RubyIndexer::Entry, skip_prefix_tree: T::Boolean).void } def add(entry, skip_prefix_tree: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#62 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#15 + sig { returns(::RubyIndexer::Configuration) } + def configuration; end + + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#67 sig { params(indexable: ::RubyIndexer::IndexablePath).void } def delete(indexable); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#570 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#575 sig { returns(T::Boolean) } def empty?; end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#590 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#595 sig { params(name: ::String).returns(::RubyIndexer::Entry::SingletonClass) } def existing_or_new_singleton_class(name); end # Searches for a constant based on an unqualified name and returns the first possible match regardless of whether # there are more possible matching entries # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#120 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#125 sig do params( name: ::String @@ -824,20 +826,20 @@ class RubyIndexer::Index # `Something::Else`, then we first discover `Something::Else::Baz`. But `Something::Else::Baz` might contain other # aliases, so we have to invoke `follow_aliased_namespace` again to check until we only return a real name # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#361 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#366 sig { params(name: ::String, seen_names: T::Array[::String]).returns(::String) } def follow_aliased_namespace(name, seen_names = T.unsafe(nil)); end # Fuzzy searches index entries based on Jaro-Winkler similarity. If no query is provided, all entries are returned # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#169 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#174 sig { params(query: T.nilable(::String)).returns(T::Array[::RubyIndexer::Entry]) } def fuzzy_search(query); end # Synchronizes a change made to the given indexable path. This method will ensure that new declarations are indexed, # removed declarations removed and that the ancestor linearization cache is cleared if necessary # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#542 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#547 sig { params(indexable: ::RubyIndexer::IndexablePath).void } def handle_change(indexable); end @@ -845,7 +847,7 @@ class RubyIndexer::Index # and control indexing progress. That block is invoked with the current progress percentage and should return `true` # to continue indexing or `false` to stop indexing. # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#299 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#304 sig do params( indexable_paths: T::Array[::RubyIndexer::IndexablePath], @@ -854,22 +856,22 @@ class RubyIndexer::Index end def index_all(indexable_paths: T.unsafe(nil), &block); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#315 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#320 sig { params(indexable_path: ::RubyIndexer::IndexablePath, source: T.nilable(::String)).void } def index_single(indexable_path, source = T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#580 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#585 sig { params(name: ::String).returns(T::Boolean) } def indexed?(name); end # Returns a list of possible candidates for completion of instance variables for a given owner name. The name must # include the `@` prefix # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#530 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#535 sig { params(name: ::String, owner_name: ::String).returns(T::Array[::RubyIndexer::Entry::InstanceVariable]) } def instance_variable_completion_candidates(name, owner_name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#585 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#590 sig { returns(::Integer) } def length; end @@ -884,11 +886,11 @@ class RubyIndexer::Index # # @raise [NonExistingNamespaceError] # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#439 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#444 sig { params(fully_qualified_name: ::String).returns(T::Array[::String]) } def linearized_ancestors_of(fully_qualified_name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#198 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#203 sig do params( name: T.nilable(::String), @@ -897,7 +899,7 @@ class RubyIndexer::Index end def method_completion_candidates(name, receiver_name); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#575 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#580 sig { returns(T::Array[::String]) } def names; end @@ -915,7 +917,7 @@ class RubyIndexer::Index # ] # ``` # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#150 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#155 sig do params( query: ::String, @@ -926,13 +928,13 @@ class RubyIndexer::Index # Register an enhancement to the index. Enhancements must conform to the `Enhancement` interface # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#51 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#56 sig { params(enhancement: ::RubyIndexer::Enhancement).void } def register_enhancement(enhancement); end # Register an included `hook` that will be executed when `module_name` is included into any namespace # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#57 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#62 sig do params( module_name: ::String, @@ -949,7 +951,7 @@ class RubyIndexer::Index # seen_names: this parameter should not be used by consumers of the api. It is used to avoid infinite recursion when # resolving circular references # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#258 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#263 sig do params( name: ::String, @@ -962,7 +964,7 @@ class RubyIndexer::Index # Resolves an instance variable name for a given owner name. This method will linearize the ancestors of the owner # and find inherited instance variables as well # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#517 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#522 sig do params( variable_name: ::String, @@ -974,7 +976,7 @@ class RubyIndexer::Index # Attempts to find methods for a resolved fully qualified receiver name. # Returns `nil` if the method does not exist on that receiver # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#401 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#406 sig do params( method_name: ::String, @@ -984,7 +986,7 @@ class RubyIndexer::Index end def resolve_method(method_name, receiver_name, inherited_only: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#104 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#109 sig { params(query: ::String).returns(T::Array[::RubyIndexer::IndexablePath]) } def search_require_paths(query); end @@ -995,11 +997,11 @@ class RubyIndexer::Index # `A::B::A::B::Foo`. This method will remove any redundant parts from the final name based on the reference and the # nesting # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#860 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#865 sig { params(name: ::String, nesting: T::Array[::String]).returns(::String) } def build_non_redundant_full_name(name, nesting); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#898 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#903 sig do params( full_name: ::String, @@ -1011,7 +1013,7 @@ class RubyIndexer::Index # Linearize mixins for an array of namespace entries. This method will mutate the `ancestors` array with the # linearized ancestors of the mixins # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#651 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#656 sig do params( ancestors: T::Array[::String], @@ -1024,7 +1026,7 @@ class RubyIndexer::Index # Linearize the superclass of a given namespace (including modules with the implicit `Module` superclass). This # method will mutate the `ancestors` array with the linearized ancestors of the superclass # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#701 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#706 sig do params( ancestors: T::Array[::String], @@ -1037,7 +1039,7 @@ class RubyIndexer::Index end def linearize_superclass(ancestors, attached_class_name, fully_qualified_name, namespace_entries, nesting, singleton_levels); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#836 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#841 sig do params( name: ::String, @@ -1047,7 +1049,7 @@ class RubyIndexer::Index end def lookup_ancestor_chain(name, nesting, seen_names); end - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#807 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#812 sig do params( name: ::String, @@ -1060,7 +1062,7 @@ class RubyIndexer::Index # Attempts to resolve an UnresolvedAlias into a resolved Alias. If the unresolved alias is pointing to a constant # that doesn't exist, then we return the same UnresolvedAlias # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#774 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#779 sig do params( entry: ::RubyIndexer::Entry::UnresolvedConstantAlias, @@ -1072,7 +1074,7 @@ class RubyIndexer::Index # Attempt to resolve a given unresolved method alias. This method returns the resolved alias if we managed to # identify the target or the same unresolved alias entry if we couldn't # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#919 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#924 sig do params( entry: ::RubyIndexer::Entry::UnresolvedMethodAlias, @@ -1083,7 +1085,7 @@ class RubyIndexer::Index # Runs the registered included hooks # - # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#616 + # source://ruby-lsp/lib/ruby_indexer/lib/ruby_indexer/index.rb#621 sig { params(fully_qualified_name: ::String, nesting: T::Array[::String]).void } def run_included_hooks(fully_qualified_name, nesting); end end @@ -1415,7 +1417,7 @@ module RubyLsp; end class RubyLsp::Addon abstract! - # source://ruby-lsp/lib/ruby_lsp/addon.rb#87 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#92 sig { void } def initialize; end @@ -1424,17 +1426,17 @@ class RubyLsp::Addon # # @abstract # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#118 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#123 sig { abstract.params(global_state: ::RubyLsp::GlobalState, outgoing_queue: ::Thread::Queue).void } def activate(global_state, outgoing_queue); end - # source://ruby-lsp/lib/ruby_lsp/addon.rb#92 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#97 sig { params(error: ::StandardError).returns(T.self_type) } def add_error(error); end # Creates a new CodeLens listener. This method is invoked on every CodeLens request # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#137 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#142 sig do overridable .params( @@ -1447,7 +1449,7 @@ class RubyLsp::Addon # Creates a new Completion listener. This method is invoked on every Completion request # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#189 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#194 sig do overridable .params( @@ -1461,7 +1463,7 @@ class RubyLsp::Addon # Creates a new Definition listener. This method is invoked on every Definition request # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#178 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#183 sig do overridable .params( @@ -1475,7 +1477,7 @@ class RubyLsp::Addon # Creates a new DocumentSymbol listener. This method is invoked on every DocumentSymbol request # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#156 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#161 sig do overridable .params( @@ -1487,7 +1489,7 @@ class RubyLsp::Addon # Creates a new Hover listener. This method is invoked on every Hover request # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#147 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#152 sig do overridable .params( @@ -1498,7 +1500,7 @@ class RubyLsp::Addon end def create_hover_listener(response_builder, node_context, dispatcher); end - # source://ruby-lsp/lib/ruby_lsp/addon.rb#164 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#169 sig do overridable .params( @@ -1513,19 +1515,19 @@ class RubyLsp::Addon # # @abstract # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#123 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#128 sig { abstract.void } def deactivate; end - # source://ruby-lsp/lib/ruby_lsp/addon.rb#98 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#103 sig { returns(T::Boolean) } def error?; end - # source://ruby-lsp/lib/ruby_lsp/addon.rb#111 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#116 sig { returns(::String) } def errors_details; end - # source://ruby-lsp/lib/ruby_lsp/addon.rb#103 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#108 sig { returns(::String) } def formatted_errors; end @@ -1533,7 +1535,7 @@ class RubyLsp::Addon # # @abstract # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#127 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#132 sig { abstract.returns(::String) } def name; end @@ -1562,7 +1564,7 @@ class RubyLsp::Addon # Intended for use by tests for addons # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#78 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#83 sig { params(addon_name: ::String).returns(::RubyLsp::Addon) } def get(addon_name); end @@ -1572,19 +1574,145 @@ class RubyLsp::Addon sig { params(child_class: T.class_of(RubyLsp::Addon)).void } def inherited(child_class); end - # Discovers and loads all addons. Returns the list of activated addons + # Discovers and loads all addons. Returns a list of errors when trying to require addons # - # source://ruby-lsp/lib/ruby_lsp/addon.rb#54 + # source://ruby-lsp/lib/ruby_lsp/addon.rb#56 sig do params( global_state: ::RubyLsp::GlobalState, outgoing_queue: ::Thread::Queue - ).returns(T::Array[::RubyLsp::Addon]) + ).returns(T::Array[::StandardError]) end def load_addons(global_state, outgoing_queue); end end end +# @abstract It cannot be directly instantiated. Subclasses must implement the `abstract` methods below. +# +# source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#6 +class RubyLsp::Addon::ProcessClient + abstract! + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#34 + sig { params(addon: ::RubyLsp::Addon, command: ::String).void } + def initialize(addon, command); end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#19 + sig { returns(::RubyLsp::Addon) } + def addon; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#96 + sig { params(message: ::String).void } + def log_output(message); end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#80 + sig { void } + def shutdown; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#28 + sig { returns(::IO) } + def stderr; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#22 + sig { returns(::IO) } + def stdin; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#25 + sig { returns(::IO) } + def stdout; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#91 + sig { returns(T::Boolean) } + def stopped?; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#31 + sig { returns(::Process::Waiter) } + def wait_thread; end + + private + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#156 + sig { void } + def force_kill; end + + # @abstract + # + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#165 + sig { abstract.params(response: T::Hash[::Symbol, T.untyped]).void } + def handle_initialize_response(response); end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#108 + sig do + params( + request: ::String, + params: T.nilable(T::Hash[::Symbol, T.untyped]) + ).returns(T.nilable(T::Hash[::Symbol, T.untyped])) + end + def make_request(request, params = T.unsafe(nil)); end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#131 + sig { overridable.returns(T.nilable(T::Hash[::Symbol, T.untyped])) } + def read_response; end + + # @abstract + # + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#162 + sig { abstract.void } + def register_exit_handler; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#114 + sig { overridable.params(request: ::String, params: T.nilable(T::Hash[::Symbol, T.untyped])).void } + def send_message(request, params = T.unsafe(nil)); end + + # Notifications are like messages, but one-way, with no response sent back. + # + # source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#128 + sig { params(request: ::String, params: T.nilable(T::Hash[::Symbol, T.untyped])).void } + def send_notification(request, params = T.unsafe(nil)); end +end + +# source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#9 +class RubyLsp::Addon::ProcessClient::EmptyMessageError < ::StandardError; end + +# source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#8 +class RubyLsp::Addon::ProcessClient::IncompleteMessageError < ::StandardError; end + +# source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#7 +class RubyLsp::Addon::ProcessClient::InitializationError < ::StandardError; end + +# source://ruby-lsp/lib/ruby_lsp/addon/process_client.rb#11 +RubyLsp::Addon::ProcessClient::MAX_RETRIES = T.let(T.unsafe(nil), Integer) + +# @abstract It cannot be directly instantiated. Subclasses must implement the `abstract` methods below. +# +# source://ruby-lsp/lib/ruby_lsp/addon/process_server.rb#6 +class RubyLsp::Addon::ProcessServer + abstract! + + # source://ruby-lsp/lib/ruby_lsp/addon/process_server.rb#15 + sig { void } + def initialize; end + + # @abstract + # + # source://ruby-lsp/lib/ruby_lsp/addon/process_server.rb#45 + sig { abstract.params(request: ::String, params: T.untyped).returns(T.untyped) } + def execute(request, params); end + + # @abstract + # + # source://ruby-lsp/lib/ruby_lsp/addon/process_server.rb#42 + sig { abstract.returns(::String) } + def generate_initialize_response; end + + # source://ruby-lsp/lib/ruby_lsp/addon/process_server.rb#24 + sig { void } + def start; end +end + +# source://ruby-lsp/lib/ruby_lsp/addon/process_server.rb#12 +RubyLsp::Addon::ProcessServer::VOID = T.let(T.unsafe(nil), Object) + # Used to indicate that a request shouldn't return a response # # source://ruby-lsp/lib/ruby_lsp/utils.rb#12 @@ -1624,6 +1752,10 @@ class RubyLsp::BaseServer sig { params(id: ::Integer).void } def send_empty_response(id); end + # source://ruby-lsp/lib/ruby_lsp/base_server.rb#150 + sig { params(message: ::String, type: ::Integer).void } + def send_log_message(message, type: T.unsafe(nil)); end + # source://ruby-lsp/lib/ruby_lsp/base_server.rb#134 sig { params(message: T.any(::RubyLsp::Error, ::RubyLsp::Notification, ::RubyLsp::Request, ::RubyLsp::Result)).void } def send_message(message); end @@ -1646,222 +1778,219 @@ RubyLsp::Constant = LanguageServer::Protocol::Constant # # source://ruby-lsp/lib/ruby_lsp/document.rb#5 class RubyLsp::Document + extend T::Generic + abstract! - # source://ruby-lsp/lib/ruby_lsp/document.rb#44 + ParseResultType = type_member + + # source://ruby-lsp/lib/ruby_lsp/document.rb#46 sig { params(source: ::String, version: ::Integer, uri: ::URI::Generic, encoding: ::Encoding).void } def initialize(source:, version:, uri:, encoding: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/document.rb#55 - sig { params(other: ::RubyLsp::Document).returns(T::Boolean) } + # source://ruby-lsp/lib/ruby_lsp/document.rb#58 + sig { params(other: RubyLsp::Document[T.untyped]).returns(T::Boolean) } def ==(other); end # TODO: remove this method once all nonpositional requests have been migrated to the listener pattern # - # source://ruby-lsp/lib/ruby_lsp/document.rb#70 + # source://ruby-lsp/lib/ruby_lsp/document.rb#73 sig do type_parameters(:T) .params( request_name: ::String, - block: T.proc.params(document: ::RubyLsp::Document).returns(T.type_parameter(:T)) + block: T.proc.params(document: RubyLsp::Document[ParseResultType]).returns(T.type_parameter(:T)) ).returns(T.type_parameter(:T)) end def cache_fetch(request_name, &block); end - # source://ruby-lsp/lib/ruby_lsp/document.rb#85 + # source://ruby-lsp/lib/ruby_lsp/document.rb#88 sig { params(request_name: ::String).returns(T.untyped) } def cache_get(request_name); end - # source://ruby-lsp/lib/ruby_lsp/document.rb#80 + # source://ruby-lsp/lib/ruby_lsp/document.rb#83 sig { type_parameters(:T).params(request_name: ::String, value: T.type_parameter(:T)).returns(T.type_parameter(:T)) } def cache_set(request_name, value); end - # source://ruby-lsp/lib/ruby_lsp/document.rb#113 + # source://ruby-lsp/lib/ruby_lsp/document.rb#116 sig { returns(::RubyLsp::Document::Scanner) } def create_scanner; end - # source://ruby-lsp/lib/ruby_lsp/document.rb#41 + # source://ruby-lsp/lib/ruby_lsp/document.rb#40 sig { returns(::Encoding) } def encoding; end # @abstract # - # source://ruby-lsp/lib/ruby_lsp/document.rb#60 + # source://ruby-lsp/lib/ruby_lsp/document.rb#63 sig { abstract.returns(::RubyLsp::Document::LanguageId) } def language_id; end - # source://ruby-lsp/lib/ruby_lsp/document.rb#134 - sig do - params( - node: ::Prism::Node, - char_position: ::Integer, - node_types: T::Array[T.class_of(Prism::Node)] - ).returns(::RubyLsp::NodeContext) - end - def locate(node, char_position, node_types: T.unsafe(nil)); end - - # source://ruby-lsp/lib/ruby_lsp/document.rb#232 - sig do - params( - range: T::Hash[::Symbol, T.untyped], - node_types: T::Array[T.class_of(Prism::Node)] - ).returns(T.nilable(::Prism::Node)) - end - def locate_first_within_range(range, node_types: T.unsafe(nil)); end - - # source://ruby-lsp/lib/ruby_lsp/document.rb#123 - sig do - params( - position: T::Hash[::Symbol, T.untyped], - node_types: T::Array[T.class_of(Prism::Node)] - ).returns(::RubyLsp::NodeContext) - end - def locate_node(position, node_types: T.unsafe(nil)); end - # @abstract # - # source://ruby-lsp/lib/ruby_lsp/document.rb#107 - sig { abstract.returns(::Prism::ParseResult) } + # source://ruby-lsp/lib/ruby_lsp/document.rb#110 + sig { abstract.returns(ParseResultType) } def parse; end - # source://ruby-lsp/lib/ruby_lsp/document.rb#29 - sig { returns(::Prism::ParseResult) } + # source://ruby-lsp/lib/ruby_lsp/document.rb#28 + sig { returns(ParseResultType) } def parse_result; end - # source://ruby-lsp/lib/ruby_lsp/document.rb#90 + # source://ruby-lsp/lib/ruby_lsp/document.rb#121 + sig { returns(T::Boolean) } + def past_expensive_limit?; end + + # source://ruby-lsp/lib/ruby_lsp/document.rb#93 sig { params(edits: T::Array[T::Hash[::Symbol, T.untyped]], version: ::Integer).void } def push_edits(edits, version:); end - # source://ruby-lsp/lib/ruby_lsp/document.rb#261 - sig { returns(::RubyLsp::Document::SorbetLevel) } - def sorbet_level; end + # source://ruby-lsp/lib/ruby_lsp/document.rb#43 + sig { returns(T.any(::LanguageServer::Protocol::Interface::SemanticTokens, ::Object)) } + def semantic_tokens; end + + # @return [Interface::SemanticTokens, Object] + # + # source://ruby-lsp/lib/ruby_lsp/document.rb#43 + def semantic_tokens=(_arg0); end - # source://ruby-lsp/lib/ruby_lsp/document.rb#32 + # source://ruby-lsp/lib/ruby_lsp/document.rb#31 sig { returns(::String) } def source; end # @abstract # - # source://ruby-lsp/lib/ruby_lsp/document.rb#110 + # source://ruby-lsp/lib/ruby_lsp/document.rb#113 sig { abstract.returns(T::Boolean) } def syntax_error?; end - # source://ruby-lsp/lib/ruby_lsp/document.rb#38 + # source://ruby-lsp/lib/ruby_lsp/document.rb#37 sig { returns(::URI::Generic) } def uri; end - # source://ruby-lsp/lib/ruby_lsp/document.rb#35 + # source://ruby-lsp/lib/ruby_lsp/document.rb#34 sig { returns(::Integer) } def version; end end +# source://ruby-lsp/lib/ruby_lsp/document.rb#23 +RubyLsp::Document::EMPTY_CACHE = T.let(T.unsafe(nil), Object) + # source://ruby-lsp/lib/ruby_lsp/document.rb#6 class RubyLsp::Document::LanguageId < ::T::Enum enums do Ruby = new ERB = new + RBS = new end end -# source://ruby-lsp/lib/ruby_lsp/document.rb#280 +# This maximum number of characters for providing expensive features, like semantic highlighting and diagnostics. +# This is the same number used by the TypeScript extension in VS Code +# +# source://ruby-lsp/lib/ruby_lsp/document.rb#22 +RubyLsp::Document::MAXIMUM_CHARACTERS_FOR_EXPENSIVE_FEATURES = T.let(T.unsafe(nil), Integer) + +# source://ruby-lsp/lib/ruby_lsp/document.rb#125 class RubyLsp::Document::Scanner - # source://ruby-lsp/lib/ruby_lsp/document.rb#288 + # source://ruby-lsp/lib/ruby_lsp/document.rb#133 sig { params(source: ::String, encoding: ::Encoding).void } def initialize(source, encoding); end # Finds the character index inside the source string for a given line and column # - # source://ruby-lsp/lib/ruby_lsp/document.rb#297 + # source://ruby-lsp/lib/ruby_lsp/document.rb#142 sig { params(position: T::Hash[::Symbol, T.untyped]).returns(::Integer) } def find_char_position(position); end # Subtract 1 for each character after 0xFFFF in the current line from the column position, so that we hit the # right character in the UTF-8 representation # - # source://ruby-lsp/lib/ruby_lsp/document.rb#319 + # source://ruby-lsp/lib/ruby_lsp/document.rb#164 sig { params(current_position: ::Integer, requested_position: ::Integer).returns(::Integer) } def utf_16_character_position_correction(current_position, requested_position); end end -# source://ruby-lsp/lib/ruby_lsp/document.rb#283 +# source://ruby-lsp/lib/ruby_lsp/document.rb#128 RubyLsp::Document::Scanner::LINE_BREAK = T.let(T.unsafe(nil), Integer) # After character 0xFFFF, UTF-16 considers characters to have length 2 and we have to account for that # -# source://ruby-lsp/lib/ruby_lsp/document.rb#285 +# source://ruby-lsp/lib/ruby_lsp/document.rb#130 RubyLsp::Document::Scanner::SURROGATE_PAIR_START = T.let(T.unsafe(nil), Integer) -# source://ruby-lsp/lib/ruby_lsp/document.rb#13 -class RubyLsp::Document::SorbetLevel < ::T::Enum - enums do - None = new - Ignore = new - False = new - True = new - Strict = new - end -end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#5 class RubyLsp::ERBDocument < ::RubyLsp::Document - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#24 + extend T::Generic + + ParseResultType = type_member { { fixed: Prism::ParseResult } } + + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#28 sig { override.returns(::RubyLsp::Document::LanguageId) } def language_id; end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#9 - sig { override.returns(::Prism::ParseResult) } + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#38 + sig do + params( + position: T::Hash[::Symbol, T.untyped], + node_types: T::Array[T.class_of(Prism::Node)] + ).returns(::RubyLsp::NodeContext) + end + def locate_node(position, node_types: T.unsafe(nil)); end + + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#12 + sig { override.returns(ParseResultType) } def parse; end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#19 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#23 sig { override.returns(T::Boolean) } def syntax_error?; end end -# source://ruby-lsp/lib/ruby_lsp/erb_document.rb#28 +# source://ruby-lsp/lib/ruby_lsp/erb_document.rb#42 class RubyLsp::ERBDocument::ERBScanner - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#35 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#49 sig { params(source: ::String).void } def initialize(source); end # @return [String] # - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#32 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#46 def html; end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#32 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#46 sig { returns(::String) } def ruby; end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#44 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#58 sig { void } def scan; end private - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#120 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#134 sig { returns(::String) } def next_char; end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#109 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#123 sig { params(char: ::String).void } def push_char(char); end - # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#54 + # source://ruby-lsp/lib/ruby_lsp/erb_document.rb#68 sig { void } def scan_char; end end -# source://ruby-lsp/lib/ruby_lsp/utils.rb#91 +# source://ruby-lsp/lib/ruby_lsp/utils.rb#100 class RubyLsp::Error - # source://ruby-lsp/lib/ruby_lsp/utils.rb#98 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#107 sig { params(id: ::Integer, code: ::Integer, message: ::String, data: T.nilable(T::Hash[::Symbol, T.untyped])).void } def initialize(id:, code:, message:, data: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#95 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#104 sig { returns(::String) } def message; end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#106 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#115 sig { returns(T::Hash[::Symbol, T.untyped]) } def to_hash; end end @@ -1886,15 +2015,17 @@ class RubyLsp::GlobalState sig { returns(T::Array[::RubyLsp::Requests::Support::Formatter]) } def active_linters; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#61 - sig { params(options: T::Hash[::Symbol, T.untyped]).void } + # 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#62 + sig { params(options: T::Hash[::Symbol, T.untyped]).returns(T::Array[::RubyLsp::Notification]) } def apply_options(options); end # source://ruby-lsp/lib/ruby_lsp/global_state.rb#21 sig { returns(::Encoding) } def encoding; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#102 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#131 sig { returns(::String) } def encoding_name; end @@ -1936,48 +2067,48 @@ class RubyLsp::GlobalState sig { returns(::RubyLsp::TypeInferrer) } def type_inferrer; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#97 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#126 sig { returns(::String) } def workspace_path; end private - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#181 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#201 sig { returns(T::Boolean) } def bin_rails_present; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#116 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#145 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#132 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#161 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#143 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#172 sig { params(dependencies: T::Array[::String]).returns(::String) } def detect_test_library(dependencies); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#163 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#192 sig { params(dependencies: T::Array[::String]).returns(T::Boolean) } def detect_typechecker(dependencies); end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#186 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#206 sig { returns(T::Boolean) } def dot_rubocop_yml_present; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#206 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#226 sig { returns(T::Array[::String]) } def gather_direct_and_indirect_dependencies; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#191 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#211 sig { returns(T::Array[::String]) } def gather_direct_dependencies; end - # source://ruby-lsp/lib/ruby_lsp/global_state.rb#199 + # source://ruby-lsp/lib/ruby_lsp/global_state.rb#219 sig { returns(T::Array[::String]) } def gemspec_dependencies; end end @@ -2084,7 +2215,7 @@ class RubyLsp::Listeners::Completion response_builder: RubyLsp::ResponseBuilders::CollectionResponseBuilder[::LanguageServer::Protocol::Interface::CompletionItem], global_state: ::RubyLsp::GlobalState, node_context: ::RubyLsp::NodeContext, - sorbet_level: ::RubyLsp::Document::SorbetLevel, + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel, dispatcher: ::Prism::Dispatcher, uri: ::URI::Generic, trigger_character: T.nilable(::String) @@ -2219,7 +2350,7 @@ class RubyLsp::Listeners::Definition uri: ::URI::Generic, node_context: ::RubyLsp::NodeContext, dispatcher: ::Prism::Dispatcher, - sorbet_level: ::RubyLsp::Document::SorbetLevel + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel ).void end def initialize(response_builder, global_state, language_id, uri, node_context, dispatcher, sorbet_level); end @@ -2282,11 +2413,11 @@ class RubyLsp::Listeners::Definition private - # source://ruby-lsp/lib/ruby_lsp/listeners/definition.rb#278 + # source://ruby-lsp/lib/ruby_lsp/listeners/definition.rb#281 sig { params(value: ::String).void } def find_in_index(value); end - # source://ruby-lsp/lib/ruby_lsp/listeners/definition.rb#267 + # source://ruby-lsp/lib/ruby_lsp/listeners/definition.rb#270 sig { params(node: ::Prism::CallNode).void } def handle_autoload_definition(node); end @@ -2304,7 +2435,7 @@ class RubyLsp::Listeners::Definition end def handle_method_definition(message, receiver_type, inherited_only: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/listeners/definition.rb#232 + # source://ruby-lsp/lib/ruby_lsp/listeners/definition.rb#235 sig { params(node: ::Prism::StringNode, message: ::Symbol).void } def handle_require_definition(node, message); end @@ -2904,7 +3035,7 @@ class RubyLsp::Listeners::Hover uri: ::URI::Generic, node_context: ::RubyLsp::NodeContext, dispatcher: ::Prism::Dispatcher, - sorbet_level: ::RubyLsp::Document::SorbetLevel + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel ).void end def initialize(response_builder, global_state, uri, node_context, dispatcher, sorbet_level); end @@ -3008,6 +3139,12 @@ class RubyLsp::Listeners::InlayHints # source://ruby-lsp/lib/ruby_lsp/listeners/inlay_hints.rb#29 sig { params(node: ::Prism::RescueNode).void } def on_rescue_node_enter(node); end + + private + + # source://ruby-lsp/lib/ruby_lsp/listeners/inlay_hints.rb#76 + sig { params(node: T.nilable(::Prism::Node), range: T.nilable(T::Range[::Integer])).returns(T::Boolean) } + def visible?(node, range); end end # source://ruby-lsp/lib/ruby_lsp/listeners/inlay_hints.rb#10 @@ -3017,158 +3154,113 @@ RubyLsp::Listeners::InlayHints::RESCUE_STRING_LENGTH = T.let(T.unsafe(nil), Inte class RubyLsp::Listeners::SemanticHighlighting include ::RubyLsp::Requests::Support::Common - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#28 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#27 sig do params( dispatcher: ::Prism::Dispatcher, - response_builder: RubyLsp::ResponseBuilders::SemanticHighlighting, - range: T.nilable(T::Range[::Integer]) + response_builder: RubyLsp::ResponseBuilders::SemanticHighlighting ).void end - def initialize(dispatcher, response_builder, range: T.unsafe(nil)); end + def initialize(dispatcher, response_builder); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#174 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#120 sig { params(node: ::Prism::BlockLocalVariableNode).void } def on_block_local_variable_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#164 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#110 sig { params(node: ::Prism::BlockNode).void } def on_block_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#169 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#115 sig { params(node: ::Prism::BlockNode).void } def on_block_node_leave(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#179 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#125 sig { params(node: ::Prism::BlockParameterNode).void } def on_block_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#75 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#62 sig { params(node: ::Prism::CallNode).void } def on_call_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#303 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#192 sig { params(node: ::Prism::ClassNode).void } def on_class_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#123 - sig { params(node: ::Prism::ConstantAndWriteNode).void } - def on_constant_and_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#130 - sig { params(node: ::Prism::ConstantOperatorWriteNode).void } - def on_constant_operator_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#137 - sig { params(node: ::Prism::ConstantOrWriteNode).void } - def on_constant_or_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#379 - sig { params(node: ::Prism::ConstantPathNode).void } - def on_constant_path_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#108 - sig { params(node: ::Prism::ConstantReadNode).void } - def on_constant_read_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#144 - sig { params(node: ::Prism::ConstantTargetNode).void } - def on_constant_target_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#116 - sig { params(node: ::Prism::ConstantWriteNode).void } - def on_constant_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#151 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#100 sig { params(node: ::Prism::DefNode).void } def on_def_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#159 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#105 sig { params(node: ::Prism::DefNode).void } def on_def_node_leave(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#367 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#252 sig { params(node: ::Prism::ImplicitNode).void } def on_implicit_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#374 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#257 sig { params(node: ::Prism::ImplicitNode).void } def on_implicit_node_leave(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#203 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#141 sig { params(node: ::Prism::KeywordRestParameterNode).void } def on_keyword_rest_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#269 - sig { params(node: ::Prism::LocalVariableAndWriteNode).void } - def on_local_variable_and_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#276 - sig { params(node: ::Prism::LocalVariableOperatorWriteNode).void } - def on_local_variable_operator_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#283 - sig { params(node: ::Prism::LocalVariableOrWriteNode).void } - def on_local_variable_or_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#255 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#168 sig { params(node: ::Prism::LocalVariableReadNode).void } def on_local_variable_read_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#290 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#181 sig { params(node: ::Prism::LocalVariableTargetNode).void } def on_local_variable_target_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#248 - sig { params(node: ::Prism::LocalVariableWriteNode).void } - def on_local_variable_write_node_enter(node); end - - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#93 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#85 sig { params(node: ::Prism::MatchWriteNode).void } def on_match_write_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#103 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#95 sig { params(node: ::Prism::MatchWriteNode).void } def on_match_write_node_leave(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#344 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#231 sig { params(node: ::Prism::ModuleNode).void } def on_module_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#194 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#136 sig { params(node: ::Prism::OptionalKeywordParameterNode).void } def on_optional_keyword_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#214 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#147 sig { params(node: ::Prism::OptionalParameterNode).void } def on_optional_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#185 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#131 sig { params(node: ::Prism::RequiredKeywordParameterNode).void } def on_required_keyword_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#222 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#152 sig { params(node: ::Prism::RequiredParameterNode).void } def on_required_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#230 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#157 sig { params(node: ::Prism::RestParameterNode).void } def on_rest_parameter_node_enter(node); end - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#241 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#163 sig { params(node: ::Prism::SelfNode).void } def on_self_node_enter(node); end private - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#396 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#271 sig { params(node: ::Prism::CallNode).void } def process_regexp_locals(node); end # Textmate provides highlighting for a subset of these special Ruby-specific methods. We want to utilize that # highlighting, so we avoid making a semantic token for it. # - # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#391 + # source://ruby-lsp/lib/ruby_lsp/listeners/semantic_highlighting.rb#266 sig { params(method_name: ::String).returns(T::Boolean) } def special_method?(method_name); end end @@ -3187,7 +3279,7 @@ class RubyLsp::Listeners::SignatureHelp global_state: ::RubyLsp::GlobalState, node_context: ::RubyLsp::NodeContext, dispatcher: ::Prism::Dispatcher, - sorbet_level: ::RubyLsp::Document::SorbetLevel + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel ).void end def initialize(response_builder, global_state, node_context, dispatcher, sorbet_level); end @@ -3282,12 +3374,16 @@ end # source://ruby-lsp/lib/ruby_lsp/utils.rb#53 class RubyLsp::Notification < ::RubyLsp::Message - # source://ruby-lsp/lib/ruby_lsp/utils.rb#71 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#80 sig { override.returns(T::Hash[::Symbol, T.untyped]) } def to_hash; end class << self - # source://ruby-lsp/lib/ruby_lsp/utils.rb#57 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#69 + sig { params(message: ::String, type: ::Integer).returns(::RubyLsp::Notification) } + def window_log_message(message, type: T.unsafe(nil)); end + + # source://ruby-lsp/lib/ruby_lsp/utils.rb#58 sig { params(message: ::String).returns(::RubyLsp::Notification) } def window_show_error(message); end end @@ -3316,35 +3412,58 @@ class RubyLsp::ParameterScope def type_for(name); end end -# source://ruby-lsp/lib/ruby_lsp/utils.rb#76 +# source://ruby-lsp/lib/ruby_lsp/rbs_document.rb#5 +class RubyLsp::RBSDocument < ::RubyLsp::Document + extend T::Generic + + ParseResultType = type_member { { fixed: T::Array[::RBS::AST::Declarations::Base] } } + + # source://ruby-lsp/lib/ruby_lsp/rbs_document.rb#12 + sig { params(source: ::String, version: ::Integer, uri: ::URI::Generic, encoding: ::Encoding).void } + def initialize(source:, version:, uri:, encoding: T.unsafe(nil)); end + + # source://ruby-lsp/lib/ruby_lsp/rbs_document.rb#37 + sig { override.returns(::RubyLsp::Document::LanguageId) } + def language_id; end + + # source://ruby-lsp/lib/ruby_lsp/rbs_document.rb#18 + sig { override.returns(ParseResultType) } + def parse; end + + # source://ruby-lsp/lib/ruby_lsp/rbs_document.rb#32 + sig { override.returns(T::Boolean) } + def syntax_error?; end +end + +# source://ruby-lsp/lib/ruby_lsp/utils.rb#85 class RubyLsp::Request < ::RubyLsp::Message - # source://ruby-lsp/lib/ruby_lsp/utils.rb#80 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#89 sig { params(id: T.any(::Integer, ::String), method: ::String, params: ::Object).void } def initialize(id:, method:, params:); end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#86 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#95 sig { override.returns(T::Hash[::Symbol, T.untyped]) } def to_hash; end end # A request configuration, to turn on/off features # -# source://ruby-lsp/lib/ruby_lsp/utils.rb#138 +# source://ruby-lsp/lib/ruby_lsp/utils.rb#150 class RubyLsp::RequestConfig - # source://ruby-lsp/lib/ruby_lsp/utils.rb#145 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#157 sig { params(configuration: T::Hash[::Symbol, T::Boolean]).void } def initialize(configuration); end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#142 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#154 sig { returns(T::Hash[::Symbol, T::Boolean]) } def configuration; end # @return [Hash{Symbol => Boolean}] # - # source://ruby-lsp/lib/ruby_lsp/utils.rb#142 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#154 def configuration=(_arg0); end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#150 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#162 sig { params(feature: ::Symbol).returns(T.nilable(T::Boolean)) } def enabled?(feature); end end @@ -3398,7 +3517,7 @@ class RubyLsp::Requests::CodeActionResolve < ::RubyLsp::Requests::Request include ::RubyLsp::Requests::Support::Common # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#42 - sig { params(document: ::RubyLsp::Document, code_action: T::Hash[::Symbol, T.untyped]).void } + sig { params(document: RubyLsp::RubyDocument, code_action: T::Hash[::Symbol, T.untyped]).void } def initialize(document, code_action); end # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#49 @@ -3410,7 +3529,7 @@ class RubyLsp::Requests::CodeActionResolve < ::RubyLsp::Requests::Request private - # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#252 + # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#268 sig do params( range: T::Hash[::Symbol, T.untyped], @@ -3419,7 +3538,7 @@ class RubyLsp::Requests::CodeActionResolve < ::RubyLsp::Requests::Request end def create_text_edit(range, new_text); end - # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#263 + # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#279 sig { params(node: ::Prism::BlockNode, indentation: T.nilable(::String)).returns(::String) } def recursively_switch_nested_block_styles(node, indentation); end @@ -3435,7 +3554,7 @@ class RubyLsp::Requests::CodeActionResolve < ::RubyLsp::Requests::Request end def refactor_variable; end - # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#292 + # source://ruby-lsp/lib/ruby_lsp/requests/code_action_resolve.rb#308 sig { params(body: ::Prism::Node, indentation: T.nilable(::String)).returns(::String) } def switch_block_body(body, indentation); end @@ -3483,7 +3602,7 @@ class RubyLsp::Requests::CodeActions < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/code_actions.rb#45 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), range: T::Hash[::Symbol, T.untyped], context: T::Hash[::Symbol, T.untyped] ).void @@ -3508,7 +3627,7 @@ RubyLsp::Requests::CodeActions::EXTRACT_TO_METHOD_TITLE = T.let(T.unsafe(nil), S RubyLsp::Requests::CodeActions::EXTRACT_TO_VARIABLE_TITLE = T.let(T.unsafe(nil), String) # source://ruby-lsp/lib/ruby_lsp/requests/code_actions.rb#24 -RubyLsp::Requests::CodeActions::SWITCH_BLOCK_STYLE_TITLE = T.let(T.unsafe(nil), String) +RubyLsp::Requests::CodeActions::TOGGLE_BLOCK_STYLE_TITLE = T.let(T.unsafe(nil), String) # ![Code lens demo](../../code_lens.gif) # @@ -3568,10 +3687,10 @@ class RubyLsp::Requests::Completion < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/completion.rb#56 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), global_state: ::RubyLsp::GlobalState, params: T::Hash[::Symbol, T.untyped], - sorbet_level: ::RubyLsp::Document::SorbetLevel, + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel, dispatcher: ::Prism::Dispatcher ).void end @@ -3653,11 +3772,11 @@ class RubyLsp::Requests::Definition < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/definition.rb#48 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), global_state: ::RubyLsp::GlobalState, position: T::Hash[::Symbol, T.untyped], dispatcher: ::Prism::Dispatcher, - sorbet_level: ::RubyLsp::Document::SorbetLevel + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel ).void end def initialize(document, global_state, position, dispatcher, sorbet_level); end @@ -3690,7 +3809,7 @@ RubyLsp::Requests::Definition::SPECIAL_METHOD_CALLS = T.let(T.unsafe(nil), Array # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#19 class RubyLsp::Requests::Diagnostics < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#36 - sig { params(global_state: ::RubyLsp::GlobalState, document: ::RubyLsp::Document).void } + sig { params(global_state: ::RubyLsp::GlobalState, document: RubyLsp::RubyDocument).void } def initialize(global_state, document); end # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#44 @@ -3699,11 +3818,11 @@ class RubyLsp::Requests::Diagnostics < ::RubyLsp::Requests::Request private - # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#85 + # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#87 sig { returns(T::Array[::LanguageServer::Protocol::Interface::Diagnostic]) } def syntax_error_diagnostics; end - # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#62 + # source://ruby-lsp/lib/ruby_lsp/requests/diagnostics.rb#64 sig { returns(T::Array[::LanguageServer::Protocol::Interface::Diagnostic]) } def syntax_warning_diagnostics; end @@ -3739,7 +3858,7 @@ class RubyLsp::Requests::DocumentHighlight < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/document_highlight.rb#37 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), position: T::Hash[::Symbol, T.untyped], dispatcher: ::Prism::Dispatcher ).void @@ -3876,7 +3995,7 @@ end # source://ruby-lsp/lib/ruby_lsp/requests/formatting.rb#25 class RubyLsp::Requests::Formatting < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/formatting.rb#44 - sig { params(global_state: ::RubyLsp::GlobalState, document: ::RubyLsp::Document).void } + sig { params(global_state: ::RubyLsp::GlobalState, document: RubyLsp::RubyDocument).void } def initialize(global_state, document); end # source://ruby-lsp/lib/ruby_lsp/requests/formatting.rb#52 @@ -3913,11 +4032,11 @@ class RubyLsp::Requests::Hover < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/hover.rb#42 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), global_state: ::RubyLsp::GlobalState, position: T::Hash[::Symbol, T.untyped], dispatcher: ::Prism::Dispatcher, - sorbet_level: ::RubyLsp::Document::SorbetLevel + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel ).void end def initialize(document, global_state, position, dispatcher, sorbet_level); end @@ -3972,7 +4091,7 @@ class RubyLsp::Requests::InlayHints < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/inlay_hints.rb#61 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), range: T::Hash[::Symbol, T.untyped], hints_configuration: ::RubyLsp::RequestConfig, dispatcher: ::Prism::Dispatcher @@ -4009,7 +4128,7 @@ class RubyLsp::Requests::OnTypeFormatting < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/on_type_formatting.rb#51 sig do params( - document: ::RubyLsp::Document, + document: RubyLsp::RubyDocument, position: T::Hash[::Symbol, T.untyped], trigger_character: ::String, client_name: ::String @@ -4093,7 +4212,7 @@ class RubyLsp::Requests::PrepareTypeHierarchy < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/prepare_type_hierarchy.rb#43 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), index: ::RubyIndexer::Index, position: T::Hash[::Symbol, T.untyped] ).void @@ -4184,11 +4303,11 @@ class RubyLsp::Requests::Request::InvalidFormatter < ::StandardError; end class RubyLsp::Requests::SelectionRanges < ::RubyLsp::Requests::Request include ::RubyLsp::Requests::Support::Common - # source://ruby-lsp/lib/ruby_lsp/requests/selection_ranges.rb#27 - sig { params(document: ::RubyLsp::Document).void } + # source://ruby-lsp/lib/ruby_lsp/requests/selection_ranges.rb#28 + sig { params(document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument)).void } def initialize(document); end - # source://ruby-lsp/lib/ruby_lsp/requests/selection_ranges.rb#35 + # source://ruby-lsp/lib/ruby_lsp/requests/selection_ranges.rb#36 sig { override.returns(T.all(::Object, T::Array[::RubyLsp::Requests::Support::SelectionRange])) } def perform; end end @@ -4207,26 +4326,58 @@ end # some_invocation # --> semantic highlighting: method invocation # var # --> semantic highlighting: local variable # end +# +# # Strategy +# +# To maximize editor performance, the Ruby LSP will return the minimum number of semantic tokens, since applying +# them is an expensive operation for the client. This means that the server only returns tokens for ambiguous pieces +# of syntax, such as method invocations with no receivers or parenthesis (which can be confused with local +# variables). +# +# Offloading as much handling as possible to Text Mate grammars or equivalent will guarantee responsiveness in the +# editor and allow for a much smoother experience. # ``` # -# source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#23 +# source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#33 class RubyLsp::Requests::SemanticHighlighting < ::RubyLsp::Requests::Request - # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#44 + # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#118 sig do params( global_state: ::RubyLsp::GlobalState, dispatcher: ::Prism::Dispatcher, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), + previous_result_id: T.nilable(::String), range: T.nilable(T::Range[::Integer]) ).void end - def initialize(global_state, dispatcher, range: T.unsafe(nil)); end + def initialize(global_state, dispatcher, document, previous_result_id, range: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#58 - sig { override.returns(::LanguageServer::Protocol::Interface::SemanticTokens) } + # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#137 + sig do + override + .returns(T.any(::LanguageServer::Protocol::Interface::SemanticTokens, ::LanguageServer::Protocol::Interface::SemanticTokensDelta)) + end def perform; end class << self - # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#30 + # The compute_delta method receives the current semantic tokens and the previous semantic tokens and then tries + # to compute the smallest possible semantic token edit that will turn previous into current + # + # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#61 + sig do + params( + current_tokens: T::Array[::Integer], + previous_tokens: T::Array[::Integer], + result_id: ::String + ).returns(::LanguageServer::Protocol::Interface::SemanticTokensDelta) + end + def compute_delta(current_tokens, previous_tokens, result_id); end + + # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#99 + sig { returns(::Integer) } + def next_result_id; end + + # source://ruby-lsp/lib/ruby_lsp/requests/semantic_highlighting.rb#40 sig { returns(::LanguageServer::Protocol::Interface::SemanticTokensRegistrationOptions) } def provider; end end @@ -4249,7 +4400,7 @@ end # source://ruby-lsp/lib/ruby_lsp/requests/show_syntax_tree.rb#20 class RubyLsp::Requests::ShowSyntaxTree < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/show_syntax_tree.rb#24 - sig { params(document: ::RubyLsp::Document, range: T.nilable(T::Hash[::Symbol, T.untyped])).void } + sig { params(document: RubyLsp::RubyDocument, range: T.nilable(T::Hash[::Symbol, T.untyped])).void } def initialize(document, range); end # source://ruby-lsp/lib/ruby_lsp/requests/show_syntax_tree.rb#32 @@ -4288,12 +4439,12 @@ class RubyLsp::Requests::SignatureHelp < ::RubyLsp::Requests::Request # source://ruby-lsp/lib/ruby_lsp/requests/signature_help.rb#52 sig do params( - document: ::RubyLsp::Document, + document: T.any(RubyLsp::ERBDocument, RubyLsp::RubyDocument), global_state: ::RubyLsp::GlobalState, position: T::Hash[::Symbol, T.untyped], context: T.nilable(T::Hash[::Symbol, T.untyped]), dispatcher: ::Prism::Dispatcher, - sorbet_level: ::RubyLsp::Document::SorbetLevel + sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel ).void end def initialize(document, global_state, position, context, dispatcher, sorbet_level); end @@ -4360,7 +4511,7 @@ end module RubyLsp::Requests::Support::Common requires_ancestor { Kernel } - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#92 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#83 sig do params( title: ::String, @@ -4370,7 +4521,7 @@ module RubyLsp::Requests::Support::Common end def categorized_markdown_from_index_entries(title, entries, max_entries = T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#160 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#151 sig do params( node: T.any(::Prism::ConstantPathNode, ::Prism::ConstantPathTargetNode, ::Prism::ConstantReadNode) @@ -4378,7 +4529,7 @@ module RubyLsp::Requests::Support::Common end def constant_name(node); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#58 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#49 sig do params( node: ::Prism::Node, @@ -4394,15 +4545,15 @@ module RubyLsp::Requests::Support::Common # name. For example, for `Foo::Bar::Baz`, this method will invoke the block with `Foo`, then `Bar` and finally # `Baz`. # - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#185 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#176 sig { params(node: ::Prism::Node, block: T.proc.params(part: ::Prism::Node).void).void } def each_constant_path_part(node, &block); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#195 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#186 sig { params(entry: ::RubyIndexer::Entry).returns(T.nilable(::Integer)) } def kind_for_entry(entry); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#136 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#127 sig do params( title: ::String, @@ -4413,11 +4564,11 @@ module RubyLsp::Requests::Support::Common end def markdown_from_index_entries(title, entries, max_entries = T.unsafe(nil), extra_links: T.unsafe(nil)); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#168 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#159 sig { params(node: T.any(::Prism::ClassNode, ::Prism::ModuleNode)).returns(T.nilable(::String)) } def namespace_constant_name(node); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#73 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#64 sig { params(file_path: ::String).returns(T.nilable(T::Boolean)) } def not_in_dependencies?(file_path); end @@ -4433,17 +4584,13 @@ module RubyLsp::Requests::Support::Common sig { params(node: ::Prism::Node).returns(::LanguageServer::Protocol::Interface::Range) } def range_from_node(node); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#80 + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#71 sig { params(node: ::Prism::CallNode).returns(T::Boolean) } def self_receiver?(node); end - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#213 - sig { params(sorbet_level: ::RubyLsp::Document::SorbetLevel).returns(T::Boolean) } + # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#204 + sig { params(sorbet_level: ::RubyLsp::RubyDocument::SorbetLevel).returns(T::Boolean) } def sorbet_level_true_or_higher?(sorbet_level); end - - # source://ruby-lsp/lib/ruby_lsp/requests/support/common.rb#41 - sig { params(node: T.nilable(::Prism::Node), range: T.nilable(T::Range[::Integer])).returns(T::Boolean) } - def visible?(node, range); end end # @abstract Subclasses must implement the `abstract` methods below. @@ -4459,7 +4606,7 @@ module RubyLsp::Requests::Support::Formatter abstract .params( uri: ::URI::Generic, - document: ::RubyLsp::Document + document: RubyLsp::RubyDocument ).returns(T.nilable(T::Array[::LanguageServer::Protocol::Interface::Diagnostic])) end def run_diagnostic(uri, document); end @@ -4467,7 +4614,7 @@ module RubyLsp::Requests::Support::Formatter # @abstract # # source://ruby-lsp/lib/ruby_lsp/requests/support/formatter.rb#14 - sig { abstract.params(uri: ::URI::Generic, document: ::RubyLsp::Document).returns(T.nilable(::String)) } + sig { abstract.params(uri: ::URI::Generic, document: RubyLsp::RubyDocument).returns(T.nilable(::String)) } def run_formatting(uri, document); end end @@ -4487,7 +4634,7 @@ class RubyLsp::Requests::Support::RuboCopDiagnostic # encoding and file source # # source://ruby-lsp/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb#35 - sig { params(document: ::RubyLsp::Document, offense: ::RuboCop::Cop::Offense, uri: ::URI::Generic).void } + sig { params(document: RubyLsp::RubyDocument, offense: ::RuboCop::Cop::Offense, uri: ::URI::Generic).void } def initialize(document, offense, uri); end # source://ruby-lsp/lib/ruby_lsp/requests/support/rubocop_diagnostic.rb#42 @@ -4560,13 +4707,13 @@ class RubyLsp::Requests::Support::RuboCopFormatter override .params( uri: ::URI::Generic, - document: ::RubyLsp::Document + document: RubyLsp::RubyDocument ).returns(T.nilable(T::Array[::LanguageServer::Protocol::Interface::Diagnostic])) end def run_diagnostic(uri, document); end # source://ruby-lsp/lib/ruby_lsp/requests/support/rubocop_formatter.rb#21 - sig { override.params(uri: ::URI::Generic, document: ::RubyLsp::Document).returns(T.nilable(::String)) } + sig { override.params(uri: ::URI::Generic, document: RubyLsp::RubyDocument).returns(T.nilable(::String)) } def run_formatting(uri, document); end end @@ -4822,7 +4969,7 @@ class RubyLsp::ResponseBuilders::SemanticHighlighting < ::RubyLsp::ResponseBuild def last_token_matches?(location); end # source://ruby-lsp/lib/ruby_lsp/response_builders/semantic_highlighting.rb#95 - sig { override.returns(::LanguageServer::Protocol::Interface::SemanticTokens) } + sig { override.returns(T::Array[::RubyLsp::ResponseBuilders::SemanticHighlighting::SemanticToken]) } def response; end end @@ -4888,7 +5035,7 @@ class RubyLsp::ResponseBuilders::SemanticHighlighting::SemanticTokenEncoder sig do params( tokens: T::Array[::RubyLsp::ResponseBuilders::SemanticHighlighting::SemanticToken] - ).returns(::LanguageServer::Protocol::Interface::SemanticTokens) + ).returns(T::Array[::Integer]) end def encode(tokens); end @@ -4932,34 +5079,87 @@ end # The final result of running a request before its IO is finalized # -# source://ruby-lsp/lib/ruby_lsp/utils.rb#119 +# source://ruby-lsp/lib/ruby_lsp/utils.rb#128 class RubyLsp::Result - # source://ruby-lsp/lib/ruby_lsp/utils.rb#126 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#138 sig { params(id: ::Integer, response: T.untyped).void } def initialize(id:, response:); end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#123 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#135 + sig { returns(::Integer) } + def id; end + + # source://ruby-lsp/lib/ruby_lsp/utils.rb#132 sig { returns(T.untyped) } def response; end - # source://ruby-lsp/lib/ruby_lsp/utils.rb#132 + # source://ruby-lsp/lib/ruby_lsp/utils.rb#144 sig { returns(T::Hash[::Symbol, T.untyped]) } def to_hash; end end # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#5 class RubyLsp::RubyDocument < ::RubyLsp::Document - # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#20 + extend T::Generic + + ParseResultType = type_member { { fixed: Prism::ParseResult } } + + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#138 sig { override.returns(::RubyLsp::Document::LanguageId) } def language_id; end - # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#7 - sig { override.returns(::Prism::ParseResult) } + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#168 + sig do + params( + range: T::Hash[::Symbol, T.untyped], + node_types: T::Array[T.class_of(Prism::Node)] + ).returns(T.nilable(::Prism::Node)) + end + def locate_first_within_range(range, node_types: T.unsafe(nil)); end + + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#202 + sig do + params( + position: T::Hash[::Symbol, T.untyped], + node_types: T::Array[T.class_of(Prism::Node)] + ).returns(::RubyLsp::NodeContext) + end + def locate_node(position, node_types: T.unsafe(nil)); end + + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#125 + sig { override.returns(ParseResultType) } def parse; end - # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#15 + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#143 + sig { returns(::RubyLsp::RubyDocument::SorbetLevel) } + def sorbet_level; end + + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#133 sig { override.returns(T::Boolean) } def syntax_error?; end + + class << self + # source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#31 + sig do + params( + node: ::Prism::Node, + char_position: ::Integer, + node_types: T::Array[T.class_of(Prism::Node)] + ).returns(::RubyLsp::NodeContext) + end + def locate(node, char_position, node_types: T.unsafe(nil)); end + end +end + +# source://ruby-lsp/lib/ruby_lsp/ruby_document.rb#11 +class RubyLsp::RubyDocument::SorbetLevel < ::T::Enum + enums do + None = new + Ignore = new + False = new + True = new + Strict = new + end end # source://ruby-lsp/lib/ruby_lsp/server.rb#5 @@ -4974,7 +5174,7 @@ class RubyLsp::Server < ::RubyLsp::BaseServer sig { returns(::RubyLsp::GlobalState) } def global_state; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#128 + # source://ruby-lsp/lib/ruby_lsp/server.rb#131 sig { void } def load_addons; end @@ -4984,55 +5184,55 @@ class RubyLsp::Server < ::RubyLsp::BaseServer private - # source://ruby-lsp/lib/ruby_lsp/server.rb#781 + # source://ruby-lsp/lib/ruby_lsp/server.rb#953 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#842 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1014 sig { void } def check_formatter_is_available; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#519 + # source://ruby-lsp/lib/ruby_lsp/server.rb#647 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def code_action_resolve(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#824 + # source://ruby-lsp/lib/ruby_lsp/server.rb#996 sig { params(id: ::String).void } def end_progress(id); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#756 + # source://ruby-lsp/lib/ruby_lsp/server.rb#923 sig { void } def perform_initial_indexing; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#859 + # source://ruby-lsp/lib/ruby_lsp/server.rb#1031 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#805 + # source://ruby-lsp/lib/ruby_lsp/server.rb#977 sig { params(id: ::String, percentage: ::Integer).void } def progress(id, percentage); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#347 + # source://ruby-lsp/lib/ruby_lsp/server.rb#386 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def run_combined_requests(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#150 + # source://ruby-lsp/lib/ruby_lsp/server.rb#166 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def run_initialize(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#264 + # source://ruby-lsp/lib/ruby_lsp/server.rb#282 sig { void } def run_initialized; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#751 + # source://ruby-lsp/lib/ruby_lsp/server.rb#918 sig { override.void } def shutdown; end - # source://ruby-lsp/lib/ruby_lsp/server.rb#484 - sig { params(document: ::RubyLsp::Document).returns(::RubyLsp::Document::SorbetLevel) } + # source://ruby-lsp/lib/ruby_lsp/server.rb#600 + sig { params(document: RubyLsp::Document[T.untyped]).returns(::RubyLsp::RubyDocument::SorbetLevel) } def sorbet_level(document); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#502 + # source://ruby-lsp/lib/ruby_lsp/server.rb#625 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_code_action(message); end @@ -5042,35 +5242,35 @@ class RubyLsp::Server < ::RubyLsp::BaseServer # source://sorbet-runtime/0.5.11406lib/types/private/methods/_methods.rb#257 def text_document_code_lens(*args, **_arg1, &blk); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#580 + # source://ruby-lsp/lib/ruby_lsp/server.rb#717 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_completion(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#600 + # source://ruby-lsp/lib/ruby_lsp/server.rb#742 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#629 + # source://ruby-lsp/lib/ruby_lsp/server.rb#776 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_definition(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#549 + # source://ruby-lsp/lib/ruby_lsp/server.rb#683 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_diagnostic(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#316 + # source://ruby-lsp/lib/ruby_lsp/server.rb#350 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_did_change(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#300 + # source://ruby-lsp/lib/ruby_lsp/server.rb#334 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_did_close(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#280 + # source://ruby-lsp/lib/ruby_lsp/server.rb#298 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_did_open(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#436 + # source://ruby-lsp/lib/ruby_lsp/server.rb#536 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_document_highlight(message); end @@ -5092,65 +5292,67 @@ class RubyLsp::Server < ::RubyLsp::BaseServer # source://sorbet-runtime/0.5.11406lib/types/private/methods/_methods.rb#257 def text_document_folding_range(*args, **_arg1, &blk); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#407 + # source://ruby-lsp/lib/ruby_lsp/server.rb#503 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_formatting(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#464 + # source://ruby-lsp/lib/ruby_lsp/server.rb#575 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_hover(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#491 + # source://ruby-lsp/lib/ruby_lsp/server.rb#608 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_inlay_hint(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#446 + # source://ruby-lsp/lib/ruby_lsp/server.rb#552 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#701 + # source://ruby-lsp/lib/ruby_lsp/server.rb#860 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#326 + # source://ruby-lsp/lib/ruby_lsp/server.rb#360 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_selection_range(message); end - # @param message [Hash{Symbol => T.untyped}] - # @return [void] - # - # source://sorbet-runtime/0.5.11406lib/types/private/methods/_methods.rb#257 - def text_document_semantic_tokens_full(*args, **_arg1, &blk); end + # source://ruby-lsp/lib/ruby_lsp/server.rb#449 + 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#390 + # source://ruby-lsp/lib/ruby_lsp/server.rb#428 + 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#474 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#689 + # source://ruby-lsp/lib/ruby_lsp/server.rb#841 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#608 + # source://ruby-lsp/lib/ruby_lsp/server.rb#750 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def text_document_signature_help(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#721 + # source://ruby-lsp/lib/ruby_lsp/server.rb#888 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def type_hierarchy_subtypes(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#712 + # source://ruby-lsp/lib/ruby_lsp/server.rb#879 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def type_hierarchy_supertypes(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#728 + # source://ruby-lsp/lib/ruby_lsp/server.rb#895 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def workspace_dependencies(message); end - # source://ruby-lsp/lib/ruby_lsp/server.rb#649 + # source://ruby-lsp/lib/ruby_lsp/server.rb#801 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#676 + # source://ruby-lsp/lib/ruby_lsp/server.rb#828 sig { params(message: T::Hash[::Symbol, T.untyped]).void } def workspace_symbol(message); end end @@ -5161,18 +5363,18 @@ class RubyLsp::Store sig { void } def initialize; end - # source://ruby-lsp/lib/ruby_lsp/store.rb#106 + # source://ruby-lsp/lib/ruby_lsp/store.rb#110 sig do type_parameters(:T) .params( uri: ::URI::Generic, request_name: ::String, - block: T.proc.params(document: ::RubyLsp::Document).returns(T.type_parameter(:T)) + block: T.proc.params(document: RubyLsp::Document[T.untyped]).returns(T.type_parameter(:T)) ).returns(T.type_parameter(:T)) end def cache_fetch(uri, request_name, &block); end - # source://ruby-lsp/lib/ruby_lsp/store.rb#84 + # source://ruby-lsp/lib/ruby_lsp/store.rb#88 sig { void } def clear; end @@ -5185,11 +5387,11 @@ class RubyLsp::Store # source://ruby-lsp/lib/ruby_lsp/store.rb#17 def client_name=(_arg0); end - # source://ruby-lsp/lib/ruby_lsp/store.rb#94 + # source://ruby-lsp/lib/ruby_lsp/store.rb#98 sig { params(uri: ::URI::Generic).void } def delete(uri); end - # source://ruby-lsp/lib/ruby_lsp/store.rb#89 + # source://ruby-lsp/lib/ruby_lsp/store.rb#93 sig { returns(T::Boolean) } def empty?; end @@ -5203,14 +5405,14 @@ class RubyLsp::Store def features_configuration=(_arg0); end # source://ruby-lsp/lib/ruby_lsp/store.rb#37 - sig { params(uri: ::URI::Generic).returns(::RubyLsp::Document) } + sig { params(uri: ::URI::Generic).returns(RubyLsp::Document[T.untyped]) } def get(uri); end - # source://ruby-lsp/lib/ruby_lsp/store.rb#79 + # source://ruby-lsp/lib/ruby_lsp/store.rb#83 sig { params(uri: ::URI::Generic, edits: T::Array[T::Hash[::Symbol, T.untyped]], version: ::Integer).void } def push_edits(uri:, edits:, version:); end - # source://ruby-lsp/lib/ruby_lsp/store.rb#68 + # source://ruby-lsp/lib/ruby_lsp/store.rb#71 sig do params( uri: ::URI::Generic, @@ -5218,7 +5420,7 @@ class RubyLsp::Store version: ::Integer, language_id: ::RubyLsp::Document::LanguageId, encoding: ::Encoding - ).void + ).returns(RubyLsp::Document[T.untyped]) end def set(uri:, source:, version:, language_id:, encoding: T.unsafe(nil)); end @@ -5273,7 +5475,7 @@ class RubyLsp::TypeInferrer private - # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#98 + # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#136 sig { params(node: T.any(::Prism::ConstantPathNode, ::Prism::ConstantReadNode)).returns(T.nilable(::String)) } def constant_name(node); end @@ -5286,25 +5488,25 @@ class RubyLsp::TypeInferrer end def infer_receiver_for_call_node(node, node_context); end - # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#78 + # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#116 sig { params(node_context: ::RubyLsp::NodeContext).returns(::RubyLsp::TypeInferrer::Type) } def self_receiver_handling(node_context); end end # A type that was guessed based on the receiver raw name # -# source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#119 +# source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#157 class RubyLsp::TypeInferrer::GuessedType < ::RubyLsp::TypeInferrer::Type; end # A known type # -# source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#106 +# source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#144 class RubyLsp::TypeInferrer::Type - # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#113 + # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#151 sig { params(name: ::String).void } def initialize(name); end - # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#110 + # source://ruby-lsp/lib/ruby_lsp/type_inferrer.rb#148 sig { returns(::String) } def name; end end diff --git a/sorbet/tapioca/require.rb b/sorbet/tapioca/require.rb index a7af5a4e..742eb893 100644 --- a/sorbet/tapioca/require.rb +++ b/sorbet/tapioca/require.rb @@ -5,6 +5,8 @@ require "rails/all" require "ruby_lsp/internal" +require "ruby_lsp/addon/process_server" +require "ruby_lsp/addon/process_client" require "ruby_lsp/test_helper" require "minitest/unit" require "mocha/minitest" diff --git a/test/ruby_lsp_rails/runner_client_test.rb b/test/ruby_lsp_rails/runner_client_test.rb index 9ffdf5cb..33fdeb9f 100644 --- a/test/ruby_lsp_rails/runner_client_test.rb +++ b/test/ruby_lsp_rails/runner_client_test.rb @@ -8,7 +8,8 @@ module RubyLsp module Rails class RunnerClientTest < ActiveSupport::TestCase setup do - @client = T.let(RunnerClient.new, RunnerClient) + @addon = Rails::Addon.new + @client = T.let(RunnerClient.new(@addon, RunnerClient::COMMAND), RunnerClient) end teardown do @@ -45,7 +46,7 @@ class RunnerClientTest < ActiveSupport::TestCase FileUtils.mv("bin/rails", "bin/rails_backup") assert_output("", %r{Ruby LSP Rails failed to locate bin/rails in the current directory}) do - client = RunnerClient.create_client + client = RunnerClient.create_client(@addon) assert_instance_of(NullClient, client) assert_nil(client.model("User")) @@ -61,7 +62,7 @@ class RunnerClientTest < ActiveSupport::TestCase "", /Ruby LSP Rails failed to initialize server/, ) do - client = RunnerClient.create_client + client = RunnerClient.create_client(@addon) assert_instance_of(NullClient, client) assert_nil(client.model("User")) @@ -78,7 +79,7 @@ class RunnerClientTest < ActiveSupport::TestCase File.write("test/dummy/config/application.rb", content + junk) capture_subprocess_io do - client = RunnerClient.create_client + client = RunnerClient.create_client(@addon) response = T.must(client.model("User")) assert(response.key?(:columns))