Use name resolution for goto definition
This commit is contained in:
committed by
Florian Diebold
parent
dc2a8d5acc
commit
a6590ce231
@@ -34,7 +34,7 @@ pub struct HirFileId(HirFileIdRepr);
|
||||
impl HirFileId {
|
||||
/// For macro-expansion files, returns the file original source file the
|
||||
/// expansionoriginated from.
|
||||
pub(crate) fn original_file(self, db: &impl HirDatabase) -> FileId {
|
||||
pub fn original_file(self, db: &impl HirDatabase) -> FileId {
|
||||
match self.0 {
|
||||
HirFileIdRepr::File(file_id) => file_id,
|
||||
HirFileIdRepr::Macro(macro_call_id) => {
|
||||
@@ -179,6 +179,12 @@ impl DefId {
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreePtr<SyntaxNode>) {
|
||||
let loc = self.loc(db);
|
||||
let syntax = db.file_item(loc.source_item_id);
|
||||
(loc.source_item_id.file_id, syntax)
|
||||
}
|
||||
|
||||
/// For a module, returns that module; for any other def, returns the containing module.
|
||||
pub fn module(self, db: &impl HirDatabase) -> Cancelable<Module> {
|
||||
let loc = self.loc(db);
|
||||
|
||||
Reference in New Issue
Block a user