aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--crates/ra_ide/src/goto_definition.rs18
-rw-r--r--crates/ra_ide_db/src/defs.rs8
-rw-r--r--crates/ra_ide_db/src/marks.rs1
3 files changed, 26 insertions, 1 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index 1dfca819d..31f567541 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -244,6 +244,24 @@ mod tests {
244 } 244 }
245 245
246 #[test] 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
264 #[test]
247 fn goto_def_for_macros_in_use_tree() { 265 fn goto_def_for_macros_in_use_tree() {
248 check_goto( 266 check_goto(
249 " 267 "
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs
index 7cd2384e9..54543e6e4 100644
--- a/crates/ra_ide_db/src/defs.rs
+++ b/crates/ra_ide_db/src/defs.rs
@@ -11,7 +11,7 @@ use hir::{
11}; 11};
12use ra_prof::profile; 12use ra_prof::profile;
13use ra_syntax::{ 13use ra_syntax::{
14 ast::{self, AstNode}, 14 ast::{self, AstNode, NameOwner},
15 match_ast, 15 match_ast,
16}; 16};
17use test_utils::tested_by; 17use test_utils::tested_by;
@@ -115,10 +115,16 @@ pub fn classify_name(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option
115} 115}
116 116
117fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<Definition> { 117fn classify_name_inner(sema: &Semantics<RootDatabase>, name: &ast::Name) -> Option<Definition> {
118 println!("name : {} -- {:?}", name, name);
118 let parent = name.syntax().parent()?; 119 let parent = name.syntax().parent()?;
120 println!("parent : {} -- {:?}", parent, parent);
119 121
120 match_ast! { 122 match_ast! {
121 match parent { 123 match parent {
124 ast::Alias(it) => {
125 let def = sema.to_def(&it)?;
126 Some(Definition::ModuleDef(def.into()))
127 },
122 ast::BindPat(it) => { 128 ast::BindPat(it) => {
123 let local = sema.to_def(&it)?; 129 let local = sema.to_def(&it)?;
124 Some(Definition::Local(local)) 130 Some(Definition::Local(local))
diff --git a/crates/ra_ide_db/src/marks.rs b/crates/ra_ide_db/src/marks.rs
index 03b4be21c..386fe605c 100644
--- a/crates/ra_ide_db/src/marks.rs
+++ b/crates/ra_ide_db/src/marks.rs
@@ -2,6 +2,7 @@
2 2
3test_utils::marks![ 3test_utils::marks![
4 goto_def_for_macros 4 goto_def_for_macros
5 goto_def_for_use_alias
5 goto_def_for_methods 6 goto_def_for_methods
6 goto_def_for_fields 7 goto_def_for_fields
7 goto_def_for_record_fields 8 goto_def_for_record_fields