From 46271ddd6029d81e2dfe31bc1691584bc1eb8fbc Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Fri, 14 Jun 2024 15:38:13 -0400 Subject: [PATCH] Rename typechecker to has_type_checker --- lib/ruby_lsp/global_state.rb | 6 +++--- lib/ruby_lsp/listeners/completion.rb | 4 ++-- lib/ruby_lsp/listeners/hover.rb | 4 ++-- lib/ruby_lsp/server.rb | 4 ++-- lib/ruby_lsp/test_helper.rb | 2 +- test/requests/workspace_symbol_test.rb | 2 +- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/lib/ruby_lsp/global_state.rb b/lib/ruby_lsp/global_state.rb index add42053ae..111ef62f3e 100644 --- a/lib/ruby_lsp/global_state.rb +++ b/lib/ruby_lsp/global_state.rb @@ -12,7 +12,7 @@ class GlobalState attr_accessor :formatter sig { returns(T::Boolean) } - attr_reader :typechecker + attr_reader :has_type_checker sig { returns(RubyIndexer::Index) } attr_reader :index @@ -31,7 +31,7 @@ def initialize @formatter = T.let("auto", String) @linters = T.let([], T::Array[String]) @test_library = T.let("minitest", String) - @typechecker = T.let(true, T::Boolean) + @has_type_checker = T.let(true, T::Boolean) @index = T.let(RubyIndexer::Index.new, RubyIndexer::Index) @supported_formatters = T.let({}, T::Hash[String, Requests::Support::Formatter]) @supports_watching_files = T.let(false, T::Boolean) @@ -66,7 +66,7 @@ def apply_options(options) specified_linters = options.dig(:initializationOptions, :linters) @linters = specified_linters || detect_linters(direct_dependencies) @test_library = detect_test_library(direct_dependencies) - @typechecker = detect_typechecker(direct_dependencies) + @has_type_checker = detect_typechecker(direct_dependencies) encodings = options.dig(:capabilities, :general, :positionEncodings) @encoding = if !encodings || encodings.empty? diff --git a/lib/ruby_lsp/listeners/completion.rb b/lib/ruby_lsp/listeners/completion.rb index f8a22c8098..001a34f64c 100644 --- a/lib/ruby_lsp/listeners/completion.rb +++ b/lib/ruby_lsp/listeners/completion.rb @@ -42,7 +42,7 @@ def initialize(response_builder, global_state, node_context, typechecker_enabled # Handle completion on regular constant references (e.g. `Bar`) sig { params(node: Prism::ConstantReadNode).void } def on_constant_read_node_enter(node) - return if @global_state.typechecker + return if @global_state.has_type_checker name = constant_name(node) return if name.nil? @@ -63,7 +63,7 @@ def on_constant_read_node_enter(node) # Handle completion on namespaced constant references (e.g. `Foo::Bar`) sig { params(node: Prism::ConstantPathNode).void } def on_constant_path_node_enter(node) - return if @global_state.typechecker + return if @global_state.has_type_checker name = constant_name(node) return if name.nil? diff --git a/lib/ruby_lsp/listeners/hover.rb b/lib/ruby_lsp/listeners/hover.rb index 913007beac..57fc5996cd 100644 --- a/lib/ruby_lsp/listeners/hover.rb +++ b/lib/ruby_lsp/listeners/hover.rb @@ -78,14 +78,14 @@ def on_constant_read_node_enter(node) sig { params(node: Prism::ConstantWriteNode).void } def on_constant_write_node_enter(node) - return if @global_state.typechecker + return if @global_state.has_type_checker generate_hover(node.name.to_s, node.name_loc) end sig { params(node: Prism::ConstantPathNode).void } def on_constant_path_node_enter(node) - return if @global_state.typechecker + return if @global_state.has_type_checker name = constant_name(node) return if name.nil? diff --git a/lib/ruby_lsp/server.rb b/lib/ruby_lsp/server.rb index 8bac238f91..16def78a1b 100644 --- a/lib/ruby_lsp/server.rb +++ b/lib/ruby_lsp/server.rb @@ -175,7 +175,7 @@ def run_initialize(message) completion_provider: completion_provider, code_lens_provider: code_lens_provider, definition_provider: enabled_features["definition"], - workspace_symbol_provider: enabled_features["workspaceSymbol"] && !@global_state.typechecker, + workspace_symbol_provider: enabled_features["workspaceSymbol"] && !@global_state.has_type_checker, signature_help_provider: signature_help_provider, ), serverInfo: { @@ -449,7 +449,7 @@ def text_document_hover(message) sig { params(document: Document).returns(T::Boolean) } def typechecker_enabled?(document) - @global_state.typechecker && document.sorbet_sigil_is_true_or_higher + @global_state.has_type_checker && document.sorbet_sigil_is_true_or_higher end sig { params(message: T::Hash[Symbol, T.untyped]).void } diff --git a/lib/ruby_lsp/test_helper.rb b/lib/ruby_lsp/test_helper.rb index d9cb5beedb..c7f08766da 100644 --- a/lib/ruby_lsp/test_helper.rb +++ b/lib/ruby_lsp/test_helper.rb @@ -20,7 +20,7 @@ module TestHelper def with_server(source = nil, uri = Kernel.URI("file:///fake.rb"), stub_no_typechecker: false, load_addons: true, &block) server = RubyLsp::Server.new(test_mode: true) - server.global_state.stubs(:typechecker).returns(false) if stub_no_typechecker + server.global_state.stubs(:has_type_checker).returns(false) if stub_no_typechecker server.global_state.apply_options({}) if source diff --git a/test/requests/workspace_symbol_test.rb b/test/requests/workspace_symbol_test.rb index 7bf1af521d..76bf165a22 100644 --- a/test/requests/workspace_symbol_test.rb +++ b/test/requests/workspace_symbol_test.rb @@ -6,7 +6,7 @@ class WorkspaceSymbolTest < Minitest::Test def setup @global_state = RubyLsp::GlobalState.new - @global_state.stubs(:typechecker).returns(false) + @global_state.stubs(:has_type_checker).returns(false) @index = @global_state.index end