From ebb4aa6a81dbdff7f53324436c6c79524c991d88 Mon Sep 17 00:00:00 2001 From: Vinicius Stock Date: Wed, 10 Jan 2024 13:04:07 -0300 Subject: [PATCH] Rename defined_in_gem? to not_in_dependencies? (#1288) This method's name was actually not matching the implementation --- lib/ruby_lsp/requests/definition.rb | 4 ++-- lib/ruby_lsp/requests/support/common.rb | 2 +- lib/ruby_lsp/requests/workspace_symbol.rb | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/ruby_lsp/requests/definition.rb b/lib/ruby_lsp/requests/definition.rb index 31dca15f7..9d95c314d 100644 --- a/lib/ruby_lsp/requests/definition.rb +++ b/lib/ruby_lsp/requests/definition.rb @@ -113,7 +113,7 @@ def handle_method_definition(node) location = target_method.location file_path = target_method.file_path - return if @typechecker_enabled && defined_in_gem?(file_path) + return if @typechecker_enabled && not_in_dependencies?(file_path) @_response = Interface::Location.new( uri: URI::Generic.from_path(path: file_path).to_s, @@ -182,7 +182,7 @@ def find_in_index(value) # additional behavior on top of jumping to RBIs. Sorbet can already handle go to definition for all constants # in the project, even if the files are typed false file_path = entry.file_path - next if DependencyDetector.instance.typechecker && defined_in_gem?(file_path) + next if DependencyDetector.instance.typechecker && not_in_dependencies?(file_path) Interface::Location.new( uri: URI::Generic.from_path(path: file_path).to_s, diff --git a/lib/ruby_lsp/requests/support/common.rb b/lib/ruby_lsp/requests/support/common.rb index 2090e6856..8996645b4 100644 --- a/lib/ruby_lsp/requests/support/common.rb +++ b/lib/ruby_lsp/requests/support/common.rb @@ -70,7 +70,7 @@ def create_code_lens(node, title:, command_name:, arguments:, data:) end sig { params(file_path: String).returns(T.nilable(T::Boolean)) } - def defined_in_gem?(file_path) + def not_in_dependencies?(file_path) BUNDLE_PATH && !file_path.start_with?(T.must(BUNDLE_PATH)) && !file_path.start_with?(RbConfig::CONFIG["rubylibdir"]) diff --git a/lib/ruby_lsp/requests/workspace_symbol.rb b/lib/ruby_lsp/requests/workspace_symbol.rb index 3ac7051e1..b30fe12b7 100644 --- a/lib/ruby_lsp/requests/workspace_symbol.rb +++ b/lib/ruby_lsp/requests/workspace_symbol.rb @@ -35,7 +35,7 @@ def response # If the project is using Sorbet, we let Sorbet handle symbols defined inside the project itself and RBIs, but # we still return entries defined in gems to allow developers to jump directly to the source file_path = entry.file_path - next if DependencyDetector.instance.typechecker && defined_in_gem?(file_path) + next if DependencyDetector.instance.typechecker && not_in_dependencies?(file_path) # We should never show private symbols when searching the entire workspace next if entry.visibility == :private