Skip to content

Commit

Permalink
Rename typechecker to has_type_checker
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock committed Jun 14, 2024
1 parent 006e321 commit 46271dd
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
6 changes: 3 additions & 3 deletions lib/ruby_lsp/global_state.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/listeners/completion.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand All @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/listeners/hover.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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?
Expand Down
4 changes: 2 additions & 2 deletions lib/ruby_lsp/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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: {
Expand Down Expand Up @@ -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 }
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/test_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion test/requests/workspace_symbol_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit 46271dd

Please sign in to comment.