aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_analysis/src/loc2id.rs
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-20 18:50:22 +0000
committerAleksey Kladov <[email protected]>2018-11-20 18:50:22 +0000
commitcc8163439f65138c0945c37d6bddc64ced2d2143 (patch)
tree232f888acb84723ea89fdf8decd866a042df5d6b /crates/ra_analysis/src/loc2id.rs
parent1cf92c3e286232be7e0d1370b88547ca0cb6f636 (diff)
populate modules
Diffstat (limited to 'crates/ra_analysis/src/loc2id.rs')
-rw-r--r--crates/ra_analysis/src/loc2id.rs11
1 files changed, 9 insertions, 2 deletions
diff --git a/crates/ra_analysis/src/loc2id.rs b/crates/ra_analysis/src/loc2id.rs
index 87417df94..e4b55f9b0 100644
--- a/crates/ra_analysis/src/loc2id.rs
+++ b/crates/ra_analysis/src/loc2id.rs
@@ -96,14 +96,14 @@ pub(crate) struct DefId(u32);
96impl_numeric_id!(DefId); 96impl_numeric_id!(DefId);
97 97
98#[derive(Clone, Debug, PartialEq, Eq, Hash)] 98#[derive(Clone, Debug, PartialEq, Eq, Hash)]
99enum DefLoc { 99pub(crate) enum DefLoc {
100 Module { 100 Module {
101 id: ModuleId, 101 id: ModuleId,
102 source_root: SourceRootId, 102 source_root: SourceRootId,
103 }, 103 },
104 Item { 104 Item {
105 ptr: SyntaxPtr, 105 ptr: SyntaxPtr,
106 } 106 },
107} 107}
108 108
109pub(crate) trait IdDatabase: salsa::Database { 109pub(crate) trait IdDatabase: salsa::Database {
@@ -122,6 +122,13 @@ impl IdMaps {
122 pub(crate) fn fn_ptr(&self, fn_id: FnId) -> SyntaxPtr { 122 pub(crate) fn fn_ptr(&self, fn_id: FnId) -> SyntaxPtr {
123 self.inner.fns.lock().id2loc(fn_id) 123 self.inner.fns.lock().id2loc(fn_id)
124 } 124 }
125
126 pub(crate) fn def_id(&self, loc: DefLoc) -> DefId {
127 self.inner.defs.lock().loc2id(&loc)
128 }
129 pub(crate) fn def_loc(&self, def_id: DefId) -> DefLoc {
130 self.inner.defs.lock().id2loc(def_id)
131 }
125} 132}
126 133
127#[derive(Debug, Default)] 134#[derive(Debug, Default)]