diff options
author | Fedor Sakharov <[email protected]> | 2020-05-11 10:25:18 +0100 |
---|---|---|
committer | Fedor Sakharov <[email protected]> | 2020-05-11 10:25:18 +0100 |
commit | 762ec9581a4331a2726cc236c565323d0c8cdb07 (patch) | |
tree | 87dc0f219d4bf26ff5298247fc5f1247c6b89ac9 /crates | |
parent | 4578154b608fa075595103d0c933da60d55b25c8 (diff) |
Find references to a function outside module
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_ide/src/references.rs | 25 | ||||
-rw-r--r-- | crates/ra_ide_db/src/defs.rs | 1 |
2 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_ide/src/references.rs b/crates/ra_ide/src/references.rs index 555ccf295..074284b42 100644 --- a/crates/ra_ide/src/references.rs +++ b/crates/ra_ide/src/references.rs | |||
@@ -593,6 +593,31 @@ mod tests { | |||
593 | check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]); | 593 | check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]); |
594 | } | 594 | } |
595 | 595 | ||
596 | #[test] | ||
597 | fn test_find_struct_function_refs_outside_module() { | ||
598 | let code = r#" | ||
599 | mod foo { | ||
600 | pub struct Foo; | ||
601 | |||
602 | impl Foo { | ||
603 | pub fn new<|>() -> Foo { | ||
604 | Foo | ||
605 | } | ||
606 | } | ||
607 | } | ||
608 | |||
609 | fn main() { | ||
610 | let _f = foo::Foo::new(); | ||
611 | }"#; | ||
612 | |||
613 | let refs = get_all_refs(code); | ||
614 | check_result( | ||
615 | refs, | ||
616 | "new FN_DEF FileId(1) 87..150 94..97 Other", | ||
617 | &["FileId(1) 227..230 StructLiteral"], | ||
618 | ); | ||
619 | } | ||
620 | |||
596 | fn get_all_refs(text: &str) -> ReferenceSearchResult { | 621 | fn get_all_refs(text: &str) -> ReferenceSearchResult { |
597 | let (analysis, position) = single_file_with_position(text); | 622 | let (analysis, position) = single_file_with_position(text); |
598 | analysis.find_all_refs(position, None).unwrap().unwrap() | 623 | analysis.find_all_refs(position, None).unwrap().unwrap() |
diff --git a/crates/ra_ide_db/src/defs.rs b/crates/ra_ide_db/src/defs.rs index f990e3bb9..c74daff38 100644 --- a/crates/ra_ide_db/src/defs.rs +++ b/crates/ra_ide_db/src/defs.rs | |||
@@ -52,6 +52,7 @@ impl Definition { | |||
52 | let parent = id.parent_enum(db); | 52 | let parent = id.parent_enum(db); |
53 | module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent))) | 53 | module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent))) |
54 | } | 54 | } |
55 | ModuleDef::Function(f) => Some(f.visibility(db)), | ||
55 | _ => module?.visibility_of(db, def), | 56 | _ => module?.visibility_of(db, def), |
56 | }, | 57 | }, |
57 | Definition::SelfType(_) => None, | 58 | Definition::SelfType(_) => None, |