Skip to content

Commit 7bc7dac

Browse files
Copilotkwerle
andcommitted
Remove variable search from global fallback as requested
Co-authored-by: kwerle <23320+kwerle@users.noreply.github.com>
1 parent 688fd10 commit 7bc7dac

2 files changed

Lines changed: 0 additions & 40 deletions

File tree

lib/ruby_language_server/project_manager.rb

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,6 @@ def project_definitions_for(name, parent_scopes = [], class_method_filter = nil)
286286
all_scopes = RubyLanguageServer::ScopeData::Scope.where(name: name)
287287
all_scopes = all_scopes.where(class_method: class_method_filter) unless class_method_filter.nil?
288288
results.concat(all_scopes.to_a)
289-
290-
# Also search for constants/variables globally
291-
all_variables = RubyLanguageServer::ScopeData::Variable.where(name: name)
292-
results.concat(all_variables.to_a)
293289
end
294290
end
295291

spec/lib/ruby_language_server/project_manager_spec.rb

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -543,42 +543,6 @@ def process
543543
assert_equal 1, results.first[:range][:start][:line]
544544
end
545545

546-
it 'finds constants/variables defined elsewhere when not in local scope' do
547-
# Define constants in a class
548-
constants_file = <<~CODE_FILE
549-
class AppConfig
550-
DATABASE_URL = 'postgres://localhost/db'
551-
MAX_RETRIES = 3
552-
end
553-
CODE_FILE
554-
555-
# Reference from another module
556-
usage_file = <<~CODE_FILE
557-
module Application
558-
class Config
559-
def load_config
560-
DATABASE_URL
561-
end
562-
end
563-
end
564-
CODE_FILE
565-
566-
project_manager.update_document_content('constants_uri', constants_file)
567-
project_manager.tags_for_uri('constants_uri')
568-
569-
project_manager.update_document_content('usage_uri', usage_file)
570-
project_manager.tags_for_uri('usage_uri')
571-
572-
# Position on "DATABASE_URL" (line 3, character 8)
573-
position = OpenStruct.new(line: 3, character: 8)
574-
results = project_manager.possible_definitions('usage_uri', position)
575-
576-
# Should find the constant via global fallback
577-
assert_equal 1, results.length
578-
assert_equal 'constants_uri', results.first[:uri]
579-
assert_equal 1, results.first[:range][:start][:line]
580-
end
581-
582546
it 'returns empty array when nothing exists anywhere' do
583547
reference_file = <<~CODE_FILE
584548
module MyModule

0 commit comments

Comments
 (0)