mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 11:59:49 +00:00
Add ExternCrateDecl to HIR
This commit is contained in:
parent
151c750dac
commit
bcff166b3a
39 changed files with 585 additions and 167 deletions
|
@ -102,7 +102,7 @@ impl NavigationTarget {
|
|||
full_range,
|
||||
SymbolKind::Module,
|
||||
);
|
||||
res.docs = module.attrs(db).docs();
|
||||
res.docs = module.docs(db);
|
||||
res.description = Some(module.display(db).to_string());
|
||||
return res;
|
||||
}
|
||||
|
@ -217,6 +217,7 @@ impl TryToNav for Definition {
|
|||
Definition::Trait(it) => it.try_to_nav(db),
|
||||
Definition::TraitAlias(it) => it.try_to_nav(db),
|
||||
Definition::TypeAlias(it) => it.try_to_nav(db),
|
||||
Definition::ExternCrateDecl(it) => Some(it.try_to_nav(db)?),
|
||||
Definition::BuiltinType(_) => None,
|
||||
Definition::ToolModule(_) => None,
|
||||
Definition::BuiltinAttr(_) => None,
|
||||
|
@ -375,6 +376,30 @@ impl TryToNav for hir::Impl {
|
|||
}
|
||||
}
|
||||
|
||||
impl TryToNav for hir::ExternCrateDecl {
|
||||
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
|
||||
let src = self.source(db)?;
|
||||
let InFile { file_id, value } = src;
|
||||
let focus = value
|
||||
.rename()
|
||||
.map_or_else(|| value.name_ref().map(Either::Left), |it| it.name().map(Either::Right));
|
||||
let (file_id, full_range, focus_range) =
|
||||
orig_range_with_focus(db, file_id, value.syntax(), focus);
|
||||
let mut res = NavigationTarget::from_syntax(
|
||||
file_id,
|
||||
self.alias_or_name(db).unwrap_or_else(|| self.name(db)).to_smol_str(),
|
||||
focus_range,
|
||||
full_range,
|
||||
SymbolKind::Module,
|
||||
);
|
||||
|
||||
res.docs = self.docs(db);
|
||||
res.description = Some(self.display(db).to_string());
|
||||
res.container_name = container_name(db, *self);
|
||||
Some(res)
|
||||
}
|
||||
}
|
||||
|
||||
impl TryToNav for hir::Field {
|
||||
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
|
||||
let src = self.source(db)?;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue