aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_ide_api/src/references.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_ide_api/src/references.rs')
-rw-r--r--crates/ra_ide_api/src/references.rs29
1 files changed, 28 insertions, 1 deletions
diff --git a/crates/ra_ide_api/src/references.rs b/crates/ra_ide_api/src/references.rs
index 0f1ac57fc..3d647d2cb 100644
--- a/crates/ra_ide_api/src/references.rs
+++ b/crates/ra_ide_api/src/references.rs
@@ -232,7 +232,7 @@ mod tests {
232 } 232 }
233 233
234 #[test] 234 #[test]
235 fn test_find_all_refs_modules() { 235 fn test_find_all_refs_two_modules() {
236 let code = r#" 236 let code = r#"
237 //- /lib.rs 237 //- /lib.rs
238 pub mod foo; 238 pub mod foo;
@@ -270,6 +270,33 @@ mod tests {
270 assert_eq!(refs.len(), 3); 270 assert_eq!(refs.len(), 3);
271 } 271 }
272 272
273
274 // `mod foo;` is not in the results because `foo` is an `ast::Name`.
275 // So, there are two references: the first one is a definition of the `foo` module,
276 // which is the whole `foo.rs`, and the second one is in `use foo::Foo`.
277 #[test]
278 fn test_find_all_refs_decl_module() {
279 let code = r#"
280 //- /lib.rs
281 mod foo<|>;
282
283 use foo::Foo;
284
285 fn f() {
286 let i = Foo { n: 5 };
287 }
288
289 //- /foo.rs
290 pub struct Foo {
291 pub n: u32,
292 }
293 "#;
294
295 let (analysis, pos) = analysis_and_position(code);
296 let refs = analysis.find_all_refs(pos).unwrap().unwrap();
297 assert_eq!(refs.len(), 2);
298 }
299
273 fn get_all_refs(text: &str) -> ReferenceSearchResult { 300 fn get_all_refs(text: &str) -> ReferenceSearchResult {
274 let (analysis, position) = single_file_with_position(text); 301 let (analysis, position) = single_file_with_position(text);
275 analysis.find_all_refs(position).unwrap().unwrap() 302 analysis.find_all_refs(position).unwrap().unwrap()