Skip to content

Commit 19e2888

Browse files
committed
wip
Signed-off-by: Benjamin Coenen <5719034+bnjjj@users.noreply.github.com>
1 parent c3c7edb commit 19e2888

File tree

3 files changed

+26
-1
lines changed

3 files changed

+26
-1
lines changed

crates/ra_ide/src/goto_definition.rs

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -243,6 +243,24 @@ mod tests {
243243
);
244244
}
245245

246+
#[test]
247+
fn goto_def_for_use_alias() {
248+
covers!(ra_ide_db::goto_def_for_use_alias);
249+
check_goto(
250+
"
251+
//- /lib.rs
252+
use foo as <|>bar;
253+
254+
255+
//- /foo/lib.rs
256+
#[macro_export]
257+
macro_rules! foo { () => { () } }
258+
",
259+
"foo MACRO_CALL FileId(2) 0..49 29..32",
260+
"#[macro_export]\nmacro_rules! foo { () => { () } }|foo",
261+
);
262+
}
263+
246264
#[test]
247265
fn goto_def_for_macros_in_use_tree() {
248266
check_goto(

crates/ra_ide_db/src/defs.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use hir::{
1111
};
1212
use ra_prof::profile;
1313
use ra_syntax::{
14-
ast::{self, AstNode},
14+
ast::{self, AstNode, NameOwner},
1515
match_ast,
1616
};
1717
use test_utils::tested_by;
@@ -115,10 +115,16 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
115115
}
116116

117117
fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<Definition> {
118+
println!("name : {} -- {:?}", name, name);
118119
let parent = name.syntax().parent()?;
120+
println!("parent : {} -- {:?}", parent, parent);
119121

120122
match_ast! {
121123
match parent {
124+
ast::Alias(it) => {
125+
let def = sema.to_def(&it)?;
126+
Some(Definition::ModuleDef(def.into()))
127+
},
122128
ast::BindPat(it) => {
123129
let local = sema.to_def(&it)?;
124130
Some(Definition::Local(local))

crates/ra_ide_db/src/marks.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
33
test_utils::marks![
44
goto_def_for_macros
5+
goto_def_for_use_alias
56
goto_def_for_methods
67
goto_def_for_fields
78
goto_def_for_record_fields

0 commit comments

Comments
 (0)