Add NavigationTarget::from_impl_item
This commit is contained in:
@@ -3,7 +3,7 @@ use ra_syntax::{
|
||||
SyntaxNode, SyntaxNodePtr, AstNode, SmolStr, TextRange, ast,
|
||||
SyntaxKind::{self, NAME},
|
||||
};
|
||||
use hir::{ModuleSource, FieldSource, Name};
|
||||
use hir::{ModuleSource, FieldSource, Name, ImplItem};
|
||||
|
||||
use crate::{FileSymbol, db::RootDatabase};
|
||||
|
||||
@@ -174,6 +174,25 @@ impl NavigationTarget {
|
||||
)
|
||||
}
|
||||
|
||||
pub(crate) fn from_impl_item(
|
||||
db: &RootDatabase,
|
||||
impl_item: hir::ImplItem,
|
||||
) -> NavigationTarget {
|
||||
match impl_item {
|
||||
ImplItem::Method(f) => {
|
||||
NavigationTarget::from_function(db, f)
|
||||
}
|
||||
ImplItem::Const(c) => {
|
||||
let (file_id, node) = c.source(db);
|
||||
NavigationTarget::from_named(file_id.original_file(db), &*node)
|
||||
}
|
||||
ImplItem::TypeAlias(a) => {
|
||||
let (file_id, node) = a.source(db);
|
||||
NavigationTarget::from_named(file_id.original_file(db), &*node)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
pub(crate) fn assert_match(&self, expected: &str) {
|
||||
let actual = self.debug_render();
|
||||
|
||||
Reference in New Issue
Block a user