aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide/src/goto_definition.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide/src/goto_definition.rs')
-rw-r--r--crates/ra_ide/src/goto_definition.rs146
1 files changed, 73 insertions, 73 deletions
diff --git a/crates/ra_ide/src/goto_definition.rs b/crates/ra_ide/src/goto_definition.rs
index 450ce0ba7..bea7fbfa7 100644
--- a/crates/ra_ide/src/goto_definition.rs
+++ b/crates/ra_ide/src/goto_definition.rs
@@ -192,27 +192,27 @@ mod tests {
192 #[test] 192 #[test]
193 fn goto_def_for_module_declaration() { 193 fn goto_def_for_module_declaration() {
194 check_goto( 194 check_goto(
195 " 195 r#"
196 //- /lib.rs 196//- /lib.rs
197 mod <|>foo; 197mod <|>foo;
198 198
199 //- /foo.rs 199//- /foo.rs
200 // empty 200// empty
201 ", 201"#,
202 "foo SOURCE_FILE FileId(2) 0..10", 202 "foo SOURCE_FILE FileId(2) 0..9",
203 "// empty\n\n", 203 "// empty\n",
204 ); 204 );
205 205
206 check_goto( 206 check_goto(
207 " 207 r#"
208 //- /lib.rs 208//- /lib.rs
209 mod <|>foo; 209mod <|>foo;
210 210
211 //- /foo/mod.rs 211//- /foo/mod.rs
212 // empty 212// empty
213 ", 213"#,
214 "foo SOURCE_FILE FileId(2) 0..10", 214 "foo SOURCE_FILE FileId(2) 0..9",
215 "// empty\n\n", 215 "// empty\n",
216 ); 216 );
217 } 217 }
218 218
@@ -254,14 +254,14 @@ mod tests {
254 #[test] 254 #[test]
255 fn goto_def_for_use_alias() { 255 fn goto_def_for_use_alias() {
256 check_goto( 256 check_goto(
257 " 257 r#"
258 //- /lib.rs 258//- /lib.rs
259 use foo as bar<|>; 259use foo as bar<|>;
260
261 260
262 //- /foo/lib.rs 261//- /foo/lib.rs
263 #[macro_export] 262#[macro_export]
264 macro_rules! foo { () => { () } }", 263macro_rules! foo { () => { () } }
264"#,
265 "SOURCE_FILE FileId(2) 0..50", 265 "SOURCE_FILE FileId(2) 0..50",
266 "#[macro_export]\nmacro_rules! foo { () => { () } }\n", 266 "#[macro_export]\nmacro_rules! foo { () => { () } }\n",
267 ); 267 );
@@ -302,19 +302,19 @@ mod tests {
302 #[test] 302 #[test]
303 fn goto_def_for_macro_defined_fn_with_arg() { 303 fn goto_def_for_macro_defined_fn_with_arg() {
304 check_goto( 304 check_goto(
305 " 305 r#"
306 //- /lib.rs 306//- /lib.rs
307 macro_rules! define_fn { 307macro_rules! define_fn {
308 ($name:ident) => (fn $name() {}) 308 ($name:ident) => (fn $name() {})
309 } 309}
310 310
311 define_fn!(foo); 311define_fn!(foo);
312 312
313 fn bar() { 313fn bar() {
314 <|>foo(); 314 <|>foo();
315 } 315}
316 ", 316"#,
317 "foo FN_DEF FileId(1) 64..80 75..78", 317 "foo FN_DEF FileId(1) 65..81 76..79",
318 "define_fn!(foo);|foo", 318 "define_fn!(foo);|foo",
319 ); 319 );
320 } 320 }
@@ -322,19 +322,19 @@ mod tests {
322 #[test] 322 #[test]
323 fn goto_def_for_macro_defined_fn_no_arg() { 323 fn goto_def_for_macro_defined_fn_no_arg() {
324 check_goto( 324 check_goto(
325 " 325 r#"
326 //- /lib.rs 326//- /lib.rs
327 macro_rules! define_fn { 327macro_rules! define_fn {
328 () => (fn foo() {}) 328 () => (fn foo() {})
329 } 329}
330 330
331 define_fn!(); 331define_fn!();
332 332
333 fn bar() { 333fn bar() {
334 <|>foo(); 334 <|>foo();
335 } 335}
336 ", 336"#,
337 "foo FN_DEF FileId(1) 51..64 51..64", 337 "foo FN_DEF FileId(1) 52..65 52..65",
338 "define_fn!();|define_fn!();", 338 "define_fn!();|define_fn!();",
339 ); 339 );
340 } 340 }
@@ -804,40 +804,40 @@ mod tests {
804 #[test] 804 #[test]
805 fn goto_within_macro() { 805 fn goto_within_macro() {
806 check_goto( 806 check_goto(
807 " 807 r#"
808 //- /lib.rs 808//- /lib.rs
809 macro_rules! id { 809macro_rules! id {
810 ($($tt:tt)*) => ($($tt)*) 810 ($($tt:tt)*) => ($($tt)*)
811 } 811}
812 812
813 fn foo() { 813fn foo() {
814 let x = 1; 814 let x = 1;
815 id!({ 815 id!({
816 let y = <|>x; 816 let y = <|>x;
817 let z = y; 817 let z = y;
818 }); 818 });
819 } 819}
820 ", 820"#,
821 "x BIND_PAT FileId(1) 69..70", 821 "x BIND_PAT FileId(1) 70..71",
822 "x", 822 "x",
823 ); 823 );
824 824
825 check_goto( 825 check_goto(
826 " 826 r#"
827 //- /lib.rs 827//- /lib.rs
828 macro_rules! id { 828macro_rules! id {
829 ($($tt:tt)*) => ($($tt)*) 829 ($($tt:tt)*) => ($($tt)*)
830 } 830}
831 831
832 fn foo() { 832fn foo() {
833 let x = 1; 833 let x = 1;
834 id!({ 834 id!({
835 let y = x; 835 let y = x;
836 let z = <|>y; 836 let z = <|>y;
837 }); 837 });
838 } 838}
839 ", 839"#,
840 "y BIND_PAT FileId(1) 98..99", 840 "y BIND_PAT FileId(1) 99..100",
841 "y", 841 "y",
842 ); 842 );
843 } 843 }