Find references to a function outside module
This commit is contained in:
parent
4578154b60
commit
762ec9581a
2 changed files with 26 additions and 0 deletions
|
@ -593,6 +593,31 @@ mod tests {
|
||||||
check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]);
|
check_result(refs, "i BIND_PAT FileId(1) 36..37 Other", &["FileId(1) 51..52 Other Write"]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_find_struct_function_refs_outside_module() {
|
||||||
|
let code = r#"
|
||||||
|
mod foo {
|
||||||
|
pub struct Foo;
|
||||||
|
|
||||||
|
impl Foo {
|
||||||
|
pub fn new<|>() -> Foo {
|
||||||
|
Foo
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn main() {
|
||||||
|
let _f = foo::Foo::new();
|
||||||
|
}"#;
|
||||||
|
|
||||||
|
let refs = get_all_refs(code);
|
||||||
|
check_result(
|
||||||
|
refs,
|
||||||
|
"new FN_DEF FileId(1) 87..150 94..97 Other",
|
||||||
|
&["FileId(1) 227..230 StructLiteral"],
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
fn get_all_refs(text: &str) -> ReferenceSearchResult {
|
fn get_all_refs(text: &str) -> ReferenceSearchResult {
|
||||||
let (analysis, position) = single_file_with_position(text);
|
let (analysis, position) = single_file_with_position(text);
|
||||||
analysis.find_all_refs(position, None).unwrap().unwrap()
|
analysis.find_all_refs(position, None).unwrap().unwrap()
|
||||||
|
|
|
@ -52,6 +52,7 @@ impl Definition {
|
||||||
let parent = id.parent_enum(db);
|
let parent = id.parent_enum(db);
|
||||||
module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent)))
|
module?.visibility_of(db, &ModuleDef::Adt(Adt::Enum(parent)))
|
||||||
}
|
}
|
||||||
|
ModuleDef::Function(f) => Some(f.visibility(db)),
|
||||||
_ => module?.visibility_of(db, def),
|
_ => module?.visibility_of(db, def),
|
||||||
},
|
},
|
||||||
Definition::SelfType(_) => None,
|
Definition::SelfType(_) => None,
|
||||||
|
|
Loading…
Reference in a new issue