mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-27 04:19:13 +00:00
Encode edition within FileId in the hir layer
This commit is contained in:
parent
92268627a8
commit
5264f86242
160 changed files with 1117 additions and 824 deletions
|
@ -7,9 +7,8 @@ use ide_db::{
|
|||
defs::{Definition, NameClass, NameRefClass},
|
||||
helpers::pick_best_token,
|
||||
search::FileReference,
|
||||
FxIndexMap, RootDatabase,
|
||||
FileRange, FxIndexMap, RootDatabase,
|
||||
};
|
||||
use span::FileRange;
|
||||
use syntax::{ast, AstNode, SyntaxKind::IDENT};
|
||||
|
||||
use crate::{goto_definition, FilePosition, NavigationTarget, RangeInfo, TryToNav};
|
||||
|
@ -33,7 +32,7 @@ pub(crate) fn incoming_calls(
|
|||
) -> Option<Vec<CallItem>> {
|
||||
let sema = &Semantics::new(db);
|
||||
|
||||
let file = sema.parse(file_id);
|
||||
let file = sema.parse_guess_edition(file_id);
|
||||
let file = file.syntax();
|
||||
let mut calls = CallLocations::default();
|
||||
|
||||
|
@ -63,9 +62,9 @@ pub(crate) fn incoming_calls(
|
|||
});
|
||||
if let Some(nav) = nav {
|
||||
let range = sema.original_range(name.syntax());
|
||||
calls.add(nav.call_site, range);
|
||||
calls.add(nav.call_site, range.into());
|
||||
if let Some(other) = nav.def_site {
|
||||
calls.add(other, range);
|
||||
calls.add(other, range.into());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -79,7 +78,7 @@ pub(crate) fn outgoing_calls(
|
|||
FilePosition { file_id, offset }: FilePosition,
|
||||
) -> Option<Vec<CallItem>> {
|
||||
let sema = Semantics::new(db);
|
||||
let file = sema.parse(file_id);
|
||||
let file = sema.parse_guess_edition(file_id);
|
||||
let file = file.syntax();
|
||||
let token = pick_best_token(file.token_at_offset(offset), |kind| match kind {
|
||||
IDENT => 1,
|
||||
|
@ -121,7 +120,7 @@ pub(crate) fn outgoing_calls(
|
|||
Some(nav_target.into_iter().zip(iter::repeat(range)))
|
||||
})
|
||||
.flatten()
|
||||
.for_each(|(nav, range)| calls.add(nav, range));
|
||||
.for_each(|(nav, range)| calls.add(nav, range.into()));
|
||||
|
||||
Some(calls.into_items())
|
||||
}
|
||||
|
@ -144,7 +143,7 @@ impl CallLocations {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use expect_test::{expect, Expect};
|
||||
use ide_db::base_db::FilePosition;
|
||||
use ide_db::FilePosition;
|
||||
use itertools::Itertools;
|
||||
|
||||
use crate::fixture;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue