[ty] Rename `ReferenceRequestHandler` file (#21680)

This commit is contained in:
Micha Reiser 2025-11-28 16:23:29 +01:00 committed by GitHub
parent 8bcfc198b8
commit 566c959add
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 32 additions and 32 deletions

View File

@ -7,7 +7,7 @@ use ty_python_semantic::SemanticModel;
/// Find all references to a symbol at the given position.
/// Search for references across all files in the project.
pub fn goto_references(
pub fn find_references(
db: &dyn Db,
file: File,
offset: TextSize,
@ -41,7 +41,7 @@ mod tests {
impl CursorTest {
fn references(&self) -> String {
let Some(mut reference_results) =
goto_references(&self.db, self.cursor.file, self.cursor.offset, true)
find_references(&self.db, self.cursor.file, self.cursor.offset, true)
else {
return "No references found".to_string();
};
@ -84,7 +84,7 @@ mod tests {
}
#[test]
fn test_parameter_references_in_function() {
fn parameter_references_in_function() {
let test = cursor_test(
"
def calculate_sum(<CURSOR>value: int) -> int:
@ -149,28 +149,28 @@ result = calculate_sum(value=42)
}
#[test]
fn test_nonlocal_variable_references() {
fn nonlocal_variable_references() {
let test = cursor_test(
"
def outer_function():
coun<CURSOR>ter = 0
def increment():
nonlocal counter
counter += 1
return counter
def decrement():
nonlocal counter
counter -= 1
return counter
# Use counter in outer scope
initial = counter
increment()
decrement()
final = counter
return increment, decrement
",
);
@ -272,7 +272,7 @@ def outer_function():
}
#[test]
fn test_global_variable_references() {
fn global_variable_references() {
let test = cursor_test(
"
glo<CURSOR>bal_counter = 0
@ -389,7 +389,7 @@ final_value = global_counter
}
#[test]
fn test_except_handler_variable_references() {
fn except_handler_variable_references() {
let test = cursor_test(
"
try:
@ -450,7 +450,7 @@ except ValueError as err:
}
#[test]
fn test_pattern_match_as_references() {
fn pattern_match_as_references() {
let test = cursor_test(
"
match x:
@ -498,7 +498,7 @@ match x:
}
#[test]
fn test_pattern_match_mapping_rest_references() {
fn pattern_match_mapping_rest_references() {
let test = cursor_test(
"
match data:
@ -553,7 +553,7 @@ match data:
}
#[test]
fn test_function_definition_references() {
fn function_definition_references() {
let test = cursor_test(
"
def my_func<CURSOR>tion():
@ -632,7 +632,7 @@ value = my_function
}
#[test]
fn test_class_definition_references() {
fn class_definition_references() {
let test = cursor_test(
"
class My<CURSOR>Class:
@ -1105,7 +1105,7 @@ cls = MyClass
def __init__(self, pos, btn):
self.position: int = pos
self.button: str = btn
def my_func(event: Click):
match event:
case Click(x, button=a<CURSOR>b):
@ -1144,7 +1144,7 @@ cls = MyClass
def __init__(self, pos, btn):
self.position: int = pos
self.button: str = btn
def my_func(event: Click):
match event:
case Click(x, button=ab):
@ -1183,7 +1183,7 @@ cls = MyClass
def __init__(self, pos, btn):
self.position: int = pos
self.button: str = btn
def my_func(event: Click):
match event:
case Cl<CURSOR>ick(x, button=ab):
@ -1233,7 +1233,7 @@ cls = MyClass
def __init__(self, pos, btn):
self.position: int = pos
self.button: str = btn
def my_func(event: Click):
match event:
case Click(x, but<CURSOR>ton=ab):
@ -1445,7 +1445,7 @@ cls = MyClass
}
#[test]
fn test_multi_file_function_references() {
fn multi_file_function_references() {
let test = CursorTest::builder()
.source(
"utils.py",
@ -1471,7 +1471,7 @@ from utils import func
class DataProcessor:
def __init__(self):
self.multiplier = func
def process(self, value):
return func(value)
",
@ -1535,14 +1535,14 @@ class DataProcessor:
}
#[test]
fn test_multi_file_class_attribute_references() {
fn multi_file_class_attribute_references() {
let test = CursorTest::builder()
.source(
"models.py",
"
class MyModel:
a<CURSOR>ttr = 42
def get_attribute(self):
return MyModel.attr
",
@ -1613,7 +1613,7 @@ def process_model():
}
#[test]
fn test_import_alias_references_should_not_resolve_to_original() {
fn import_alias_references_should_not_resolve_to_original() {
let test = CursorTest::builder()
.source(
"original.py",

View File

@ -9,10 +9,10 @@ mod doc_highlights;
mod docstring;
mod document_symbols;
mod find_node;
mod find_references;
mod goto;
mod goto_declaration;
mod goto_definition;
mod goto_references;
mod goto_type_definition;
mod hover;
mod importer;
@ -32,8 +32,8 @@ pub use code_action::{QuickFix, code_actions};
pub use completion::{Completion, CompletionKind, CompletionSettings, completion};
pub use doc_highlights::document_highlights;
pub use document_symbols::document_symbols;
pub use find_references::find_references;
pub use goto::{goto_declaration, goto_definition, goto_type_definition};
pub use goto_references::goto_references;
pub use hover::hover;
pub use inlay_hints::{
InlayHintKind, InlayHintLabel, InlayHintSettings, InlayHintTextEdit, inlay_hints,

View File

@ -6,11 +6,11 @@ mod document_symbols;
mod execute_command;
mod goto_declaration;
mod goto_definition;
mod goto_references;
mod goto_type_definition;
mod hover;
mod inlay_hints;
mod prepare_rename;
mod references;
mod rename;
mod selection_range;
mod semantic_tokens;
@ -28,11 +28,11 @@ pub(super) use document_symbols::DocumentSymbolRequestHandler;
pub(super) use execute_command::ExecuteCommand;
pub(super) use goto_declaration::GotoDeclarationRequestHandler;
pub(super) use goto_definition::GotoDefinitionRequestHandler;
pub(super) use goto_references::ReferencesRequestHandler;
pub(super) use goto_type_definition::GotoTypeDefinitionRequestHandler;
pub(super) use hover::HoverRequestHandler;
pub(super) use inlay_hints::InlayHintRequestHandler;
pub(super) use prepare_rename::PrepareRenameRequestHandler;
pub(super) use references::ReferencesRequestHandler;
pub(super) use rename::RenameRequestHandler;
pub(super) use selection_range::SelectionRangeRequestHandler;
pub(super) use semantic_tokens::SemanticTokensRequestHandler;

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use lsp_types::request::References;
use lsp_types::{Location, ReferenceParams, Url};
use ty_ide::goto_references;
use ty_ide::find_references;
use ty_project::ProjectDatabase;
use crate::document::{PositionExt, ToLink};
@ -51,7 +51,7 @@ impl BackgroundDocumentRequestHandler for ReferencesRequestHandler {
let include_declaration = params.context.include_declaration;
let Some(references_result) = goto_references(db, file, offset, include_declaration) else {
let Some(references_result) = find_references(db, file, offset, include_declaration) else {
return Ok(None);
};

View File

@ -17,8 +17,8 @@ use ruff_python_formatter::formatted_file;
use ruff_source_file::{LineIndex, OneIndexed, SourceLocation};
use ruff_text_size::{Ranged, TextSize};
use ty_ide::{
InlayHintSettings, MarkupKind, RangedValue, document_highlights, goto_declaration,
goto_definition, goto_references, goto_type_definition, hover, inlay_hints,
InlayHintSettings, MarkupKind, RangedValue, document_highlights, find_references,
goto_declaration, goto_definition, goto_type_definition, hover, inlay_hints,
};
use ty_ide::{NavigationTarget, NavigationTargets, signature_help};
use ty_project::metadata::options::Options;
@ -351,7 +351,7 @@ impl Workspace {
let offset = position.to_text_size(&source, &index, self.position_encoding)?;
let Some(targets) = goto_references(&self.db, file_id.file, offset, true) else {
let Some(targets) = find_references(&self.db, file_id.file, offset, true) else {
return Ok(Vec::new());
};