aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_db/src/input.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_db/src/input.rs')
-rw-r--r--crates/ra_db/src/input.rs20
1 files changed, 16 insertions, 4 deletions
diff --git a/crates/ra_db/src/input.rs b/crates/ra_db/src/input.rs
index a48d05b98..37da8c549 100644
--- a/crates/ra_db/src/input.rs
+++ b/crates/ra_db/src/input.rs
@@ -20,25 +20,31 @@ pub struct CrateGraph {
20#[derive(Debug, Clone, PartialEq, Eq)] 20#[derive(Debug, Clone, PartialEq, Eq)]
21struct CrateData { 21struct CrateData {
22 file_id: FileId, 22 file_id: FileId,
23 deps: Vec<Dependency>, 23 dependencies: Vec<Dependency>,
24} 24}
25 25
26impl CrateData { 26impl CrateData {
27 fn new(file_id: FileId) -> CrateData { 27 fn new(file_id: FileId) -> CrateData {
28 CrateData { 28 CrateData {
29 file_id, 29 file_id,
30 deps: Vec::new(), 30 dependencies: Vec::new(),
31 } 31 }
32 } 32 }
33 33
34 fn add_dep(&mut self, dep: CrateId) { 34 fn add_dep(&mut self, dep: CrateId) {
35 self.deps.push(Dependency { crate_: dep }) 35 self.dependencies.push(Dependency { crate_id: dep })
36 } 36 }
37} 37}
38 38
39#[derive(Debug, Clone, PartialEq, Eq)] 39#[derive(Debug, Clone, PartialEq, Eq)]
40pub struct Dependency { 40pub struct Dependency {
41 crate_: CrateId, 41 crate_id: CrateId,
42}
43
44impl Dependency {
45 pub fn crate_id(&self) -> CrateId {
46 self.crate_id
47 }
42} 48}
43 49
44impl CrateGraph { 50impl CrateGraph {
@@ -64,6 +70,12 @@ impl CrateGraph {
64 .find(|(_crate_id, data)| data.file_id == file_id)?; 70 .find(|(_crate_id, data)| data.file_id == file_id)?;
65 Some(crate_id) 71 Some(crate_id)
66 } 72 }
73 pub fn dependencies<'a>(
74 &'a self,
75 crate_id: CrateId,
76 ) -> impl Iterator<Item = &'a Dependency> + 'a {
77 self.arena[&crate_id].dependencies.iter()
78 }
67} 79}
68 80
69salsa::query_group! { 81salsa::query_group! {