mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 12:54:58 +00:00
fix go to parent module
This commit is contained in:
parent
4209022e5b
commit
077a02271c
2 changed files with 21 additions and 2 deletions
|
@ -89,6 +89,25 @@ impl NavigationTarget {
|
|||
Ok(res)
|
||||
}
|
||||
|
||||
pub(crate) fn from_module_to_decl(
|
||||
db: &RootDatabase,
|
||||
module: hir::Module,
|
||||
) -> Cancelable<NavigationTarget> {
|
||||
let name = module
|
||||
.name(db)?
|
||||
.map(|it| it.to_string().into())
|
||||
.unwrap_or_default();
|
||||
if let Some((file_id, source)) = module.declaration_source(db)? {
|
||||
return Ok(NavigationTarget::from_syntax(
|
||||
file_id,
|
||||
name,
|
||||
None,
|
||||
source.syntax(),
|
||||
));
|
||||
}
|
||||
NavigationTarget::from_module(db, module)
|
||||
}
|
||||
|
||||
// TODO once Def::Item is gone, this should be able to always return a NavigationTarget
|
||||
pub(crate) fn from_def(db: &RootDatabase, def: Def) -> Cancelable<Option<NavigationTarget>> {
|
||||
let res = match def {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue