Skip to content

Commit

Permalink
Rename defined_in_gem? to not_in_dependencies? (#1288)
Browse files Browse the repository at this point in the history
This method's name was actually not matching the implementation
  • Loading branch information
vinistock authored Jan 10, 2024
1 parent c37838b commit ebb4aa6
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions lib/ruby_lsp/requests/definition.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/requests/support/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down
2 changes: 1 addition & 1 deletion lib/ruby_lsp/requests/workspace_symbol.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ebb4aa6

Please sign in to comment.