mirror of
https://github.com/rust-lang/rust-analyzer
synced 2024-12-27 05:23:24 +00:00
More precise navigation to parent
This commit is contained in:
parent
2ac20b05f1
commit
ef8f38efc6
3 changed files with 13 additions and 10 deletions
|
@ -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();
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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 }
|
||||
} //^^^^^^^^^^^^
|
||||
} //^^^
|
||||
}
|
||||
"#,
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue