Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
This commit is contained in:
Benjamin Coenen 2020-05-01 16:26:22 +02:00
parent c3c7edb9bc
commit 19e28888aa
3 changed files with 26 additions and 1 deletions

View File

@ -243,6 +243,24 @@ mod tests {
);
}
#[test]
fn goto_def_for_use_alias() {
covers!(ra_ide_db::goto_def_for_use_alias);
check_goto(
"
//- /lib.rs
use foo as <|>bar;
//- /foo/lib.rs
#[macro_export]
macro_rules! foo { () => { () } }
",
"foo MACRO_CALL FileId(2) 0..49 29..32",
"#[macro_export]\nmacro_rules! foo { () => { () } }|foo",
);
}
#[test]
fn goto_def_for_macros_in_use_tree() {
check_goto(

View File

@ -11,7 +11,7 @@ use hir::{
};
use ra_prof::profile;
use ra_syntax::{
ast::{self, AstNode},
ast::{self, AstNode, NameOwner},
match_ast,
};
use test_utils::tested_by;
@ -115,10 +115,16 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
}
fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<Definition> {
println!("name : {} -- {:?}", name, name);
let parent = name.syntax().parent()?;
println!("parent : {} -- {:?}", parent, parent);
match_ast! {
match parent {
ast::Alias(it) => {
let def = sema.to_def(&it)?;
Some(Definition::ModuleDef(def.into()))
},
ast::BindPat(it) => {
let local = sema.to_def(&it)?;
Some(Definition::Local(local))

View File

@ -2,6 +2,7 @@
test_utils::marks![
goto_def_for_macros
goto_def_for_use_alias
goto_def_for_methods
goto_def_for_fields
goto_def_for_record_fields