mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-26 13:03:31 +00:00
make handle_references
accept refs from other files
This commit is contained in:
parent
df8441b24e
commit
79e6b3b0d1
1 changed files with 9 additions and 4 deletions
|
@ -481,8 +481,7 @@ pub fn handle_references(
|
|||
params: req::ReferenceParams,
|
||||
) -> Result<Option<Vec<Location>>> {
|
||||
let position = params.text_document_position.try_conv_with(&world)?;
|
||||
let line_index = world.analysis().file_line_index(position.file_id)?;
|
||||
|
||||
|
||||
let refs = match world.analysis().find_all_refs(position)? {
|
||||
None => return Ok(None),
|
||||
Some(refs) => refs,
|
||||
|
@ -490,13 +489,19 @@ pub fn handle_references(
|
|||
|
||||
let locations = if params.context.include_declaration {
|
||||
refs.into_iter()
|
||||
.filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok())
|
||||
.filter_map(|r| {
|
||||
let line_index = world.analysis().file_line_index(r.file_id).ok()?;
|
||||
to_location(r.file_id, r.range, &world, &line_index).ok()
|
||||
})
|
||||
.collect()
|
||||
} else {
|
||||
// Only iterate over the references if include_declaration was false
|
||||
refs.references()
|
||||
.iter()
|
||||
.filter_map(|r| to_location(r.file_id, r.range, &world, &line_index).ok())
|
||||
.filter_map(|r| {
|
||||
let line_index = world.analysis().file_line_index(r.file_id).ok()?;
|
||||
to_location(r.file_id, r.range, &world, &line_index).ok()
|
||||
})
|
||||
.collect()
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue