Fix ConstParam HasSource impl and implement TryToNav not Nav
This commit is contained in:
@@ -142,8 +142,8 @@ impl HasSource for LifetimeParam {
|
|||||||
|
|
||||||
impl HasSource for ConstParam {
|
impl HasSource for ConstParam {
|
||||||
type Ast = ast::ConstParam;
|
type Ast = ast::ConstParam;
|
||||||
fn source(self, db: &dyn HirDatabase) -> InFile<Self::Ast> {
|
fn source(self, db: &dyn HirDatabase) -> Option<InFile<Self::Ast>> {
|
||||||
let child_source = self.id.parent.child_source(db.upcast());
|
let child_source = self.id.parent.child_source(db.upcast());
|
||||||
child_source.map(|it| it[self.id.local_id].clone())
|
Some(child_source.map(|it| it[self.id.local_id].clone()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -218,7 +218,7 @@ impl TryToNav for Definition {
|
|||||||
Definition::TypeParam(it) => it.try_to_nav(db),
|
Definition::TypeParam(it) => it.try_to_nav(db),
|
||||||
Definition::LifetimeParam(it) => it.try_to_nav(db),
|
Definition::LifetimeParam(it) => it.try_to_nav(db),
|
||||||
Definition::Label(it) => Some(it.to_nav(db)),
|
Definition::Label(it) => Some(it.to_nav(db)),
|
||||||
Definition::ConstParam(it) => Some(it.to_nav(db)),
|
Definition::ConstParam(it) => it.try_to_nav(db),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -479,11 +479,11 @@ impl TryToNav for hir::LifetimeParam {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ToNav for hir::ConstParam {
|
impl TryToNav for hir::ConstParam {
|
||||||
fn to_nav(&self, db: &RootDatabase) -> NavigationTarget {
|
fn try_to_nav(&self, db: &RootDatabase) -> Option<NavigationTarget> {
|
||||||
let src = self.source(db);
|
let src = self.source(db)?;
|
||||||
let full_range = src.value.syntax().text_range();
|
let full_range = src.value.syntax().text_range();
|
||||||
NavigationTarget {
|
Some(NavigationTarget {
|
||||||
file_id: src.file_id.original_file(db),
|
file_id: src.file_id.original_file(db),
|
||||||
name: self.name(db).to_string().into(),
|
name: self.name(db).to_string().into(),
|
||||||
kind: Some(SymbolKind::ConstParam),
|
kind: Some(SymbolKind::ConstParam),
|
||||||
@@ -492,7 +492,7 @@ impl ToNav for hir::ConstParam {
|
|||||||
container_name: None,
|
container_name: None,
|
||||||
description: None,
|
description: None,
|
||||||
docs: None,
|
docs: None,
|
||||||
}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user