diff --git a/lib/ruby_lsp/requests/definition.rb b/lib/ruby_lsp/requests/definition.rb index c948ead9f..1373c7688 100644 --- a/lib/ruby_lsp/requests/definition.rb +++ b/lib/ruby_lsp/requests/definition.rb @@ -150,9 +150,8 @@ 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 - if DependencyDetector.instance.typechecker_for_uri?(@uri) && bundle_path && !file_path.start_with?(bundle_path) && - !file_path.start_with?(RbConfig::CONFIG["rubylibdir"]) - + if DependencyDetector.instance.typechecker_for_uri?(@uri) && bundle_path && + !file_path.start_with?(bundle_path) && !file_path.start_with?(RbConfig::CONFIG["rubylibdir"]) next end diff --git a/lib/ruby_lsp/requests/support/common.rb b/lib/ruby_lsp/requests/support/common.rb index d340b4d82..0a94ebfe3 100644 --- a/lib/ruby_lsp/requests/support/common.rb +++ b/lib/ruby_lsp/requests/support/common.rb @@ -98,6 +98,11 @@ def markdown_from_index_entries(title, entries) MARKDOWN ) end + + sig { params(uri: URI::Generic).returns(T::Boolean) } + def erb?(uri) + uri.to_s.match?(/\.(?:erb|rhtml|rhtm)$/) + end end end end diff --git a/lib/ruby_lsp/requests/support/dependency_detector.rb b/lib/ruby_lsp/requests/support/dependency_detector.rb index 6e432ec26..45d8eb4ef 100644 --- a/lib/ruby_lsp/requests/support/dependency_detector.rb +++ b/lib/ruby_lsp/requests/support/dependency_detector.rb @@ -6,6 +6,7 @@ module RubyLsp class DependencyDetector include Singleton + include Support::Common extend T::Sig sig { returns(String) } @@ -89,12 +90,5 @@ def gemspec_dependencies .grep(Bundler::Source::Gemspec) .flat_map { _1.gemspec&.dependencies&.map(&:name) } end - - private - - sig { params(uri: URI::Generic).returns(T::Boolean) } - def erb?(uri) - uri.to_s.match?(/\.(?:erb|rhtml|rhtm)$/) - end end end diff --git a/lib/ruby_lsp/requests/workspace_symbol.rb b/lib/ruby_lsp/requests/workspace_symbol.rb index 26ab3141b..683671e45 100644 --- a/lib/ruby_lsp/requests/workspace_symbol.rb +++ b/lib/ruby_lsp/requests/workspace_symbol.rb @@ -40,9 +40,8 @@ def run # 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 - if DependencyDetector.instance.typechecker_for_uri?(@uri) && bundle_path && !file_path.start_with?(bundle_path) && - !file_path.start_with?(RbConfig::CONFIG["rubylibdir"]) - + if DependencyDetector.instance.typechecker_for_uri?(@uri) && bundle_path && + !file_path.start_with?(bundle_path) && !file_path.start_with?(RbConfig::CONFIG["rubylibdir"]) next end diff --git a/lib/ruby_lsp/store.rb b/lib/ruby_lsp/store.rb index 5df2fe69c..26b0ada3b 100644 --- a/lib/ruby_lsp/store.rb +++ b/lib/ruby_lsp/store.rb @@ -4,6 +4,7 @@ module RubyLsp class Store extend T::Sig + include Support::Common sig { returns(String) } attr_accessor :encoding @@ -77,10 +78,5 @@ def delete(uri) def cache_fetch(uri, request_name, &block) get(uri).cache_fetch(request_name, &block) end - - sig { params(uri: URI::Generic).returns(T::Boolean) } - def erb?(uri) - uri.to_s.match?(/\.(?:erb|rhtml|rhtm)$/) - end end end