Replace ID based TokenMap with proper relative text-ranges / spans

This commit is contained in:
Lukas Wirth 2023-09-29 12:37:57 +02:00
parent f79439caed
commit 890eb17b4e
80 changed files with 1816 additions and 2046 deletions

View file

@ -60,13 +60,13 @@ pub(crate) fn goto_definition(
.into_iter()
.filter_map(|token| {
let parent = token.parent()?;
if let Some(tt) = ast::TokenTree::cast(parent) {
if let Some(tt) = ast::TokenTree::cast(parent.clone()) {
if let Some(x) = try_lookup_include_path(sema, tt, token.clone(), file_id) {
return Some(vec![x]);
}
}
Some(
IdentClass::classify_token(sema, &token)?
IdentClass::classify_node(sema, &parent)?
.definitions()
.into_iter()
.flat_map(|def| {
@ -392,6 +392,8 @@ fn bar() {
);
}
// FIXME: We should emit two targets here, one for the identifier in the declaration, one for
// the macro call
#[test]
fn goto_def_for_macro_defined_fn_no_arg() {
check(
@ -399,10 +401,10 @@ fn bar() {
//- /lib.rs
macro_rules! define_fn {
() => (fn foo() {})
//^^^
}
define_fn!();
//^^^^^^^^^^^^^
fn bar() {
$0foo();