aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir/src/ids.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir/src/ids.rs')
-rw-r--r--crates/ra_hir/src/ids.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index db0107e53..c75ef4ae7 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -34,7 +34,7 @@ pub struct HirFileId(HirFileIdRepr);
34impl HirFileId { 34impl HirFileId {
35 /// For macro-expansion files, returns the file original source file the 35 /// For macro-expansion files, returns the file original source file the
36 /// expansionoriginated from. 36 /// expansionoriginated from.
37 pub(crate) fn original_file(self, db: &impl HirDatabase) -> FileId { 37 pub fn original_file(self, db: &impl HirDatabase) -> FileId {
38 match self.0 { 38 match self.0 {
39 HirFileIdRepr::File(file_id) => file_id, 39 HirFileIdRepr::File(file_id) => file_id,
40 HirFileIdRepr::Macro(macro_call_id) => { 40 HirFileIdRepr::Macro(macro_call_id) => {
@@ -179,6 +179,12 @@ impl DefId {
179 Ok(res) 179 Ok(res)
180 } 180 }
181 181
182 pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreePtr<SyntaxNode>) {
183 let loc = self.loc(db);
184 let syntax = db.file_item(loc.source_item_id);
185 (loc.source_item_id.file_id, syntax)
186 }
187
182 /// For a module, returns that module; for any other def, returns the containing module. 188 /// For a module, returns that module; for any other def, returns the containing module.
183 pub fn module(self, db: &impl HirDatabase) -> Cancelable<Module> { 189 pub fn module(self, db: &impl HirDatabase) -> Cancelable<Module> {
184 let loc = self.loc(db); 190 let loc = self.loc(db);