More precise navigation to parent

This commit is contained in:
Aleksey Kladov 2021-02-09 18:21:09 +03:00
parent 2ac20b05f1
commit ef8f38efc6
3 changed files with 13 additions and 10 deletions

View file

@ -85,12 +85,16 @@ impl NavigationTarget {
let name = module.name(db).map(|it| it.to_string().into()).unwrap_or_default();
if let Some(src) = module.declaration_source(db) {
let node = src.as_ref().map(|it| it.syntax());
let frange = node.original_file_range(db);
let full_range = node.original_file_range(db);
let focus_range = src
.value
.name()
.map(|name| src.with_value(name.syntax()).original_file_range(db).range);
let mut res = NavigationTarget::from_syntax(
frange.file_id,
full_range.file_id,
name,
None,
frange.range,
focus_range,
full_range.range,
SymbolKind::Module,
);
res.docs = module.attrs(db).docs();

View file

@ -131,7 +131,6 @@ pub(crate) fn reference_definition(
#[cfg(test)]
mod tests {
use ide_db::base_db::FileRange;
use syntax::{TextRange, TextSize};
use crate::fixture;

View file

@ -81,8 +81,8 @@ mod tests {
check(
r#"
//- /lib.rs
mod foo;
//^^^^^^^^
mod foo;
//^^^
//- /foo.rs
$0// empty
@ -96,8 +96,8 @@ $0// empty
check(
r#"
//- /lib.rs
mod foo;
//^^^^^^^^
mod foo;
//^^^
//- /foo.rs
mod $0bar;
@ -115,7 +115,7 @@ mod $0bar;
mod foo {
mod bar {
mod baz { $0 }
} //^^^^^^^^^^^^
} //^^^
}
"#,
);