diff options
author | Aleksey Kladov <[email protected]> | 2019-01-04 21:02:05 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2019-01-06 14:35:29 +0000 |
commit | 9a820dc0ee23051137e4909d4698fe71930c04bc (patch) | |
tree | 2917d228f7ce13a0fe0e4e92d8ca73d1cdd2f7e3 /crates/ra_hir/src/code_model_api.rs | |
parent | eaf553dade9a28b41631387d7c88b09fd0ba64e2 (diff) |
move crate to code_model_api
Diffstat (limited to 'crates/ra_hir/src/code_model_api.rs')
-rw-r--r-- | crates/ra_hir/src/code_model_api.rs | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs new file mode 100644 index 000000000..e8b3a1fb6 --- /dev/null +++ b/crates/ra_hir/src/code_model_api.rs | |||
@@ -0,0 +1,26 @@ | |||
1 | use ra_db::{CrateId, Cancelable}; | ||
2 | |||
3 | use crate::{Module, Name, db::HirDatabase}; | ||
4 | |||
5 | /// hir::Crate describes a single crate. It's the main inteface with which | ||
6 | /// crate's dependencies interact. Mostly, it should be just a proxy for the | ||
7 | /// root module. | ||
8 | #[derive(Debug, Clone, PartialEq, Eq, Hash)] | ||
9 | pub struct Crate { | ||
10 | pub(crate) crate_id: CrateId, | ||
11 | } | ||
12 | |||
13 | #[derive(Debug)] | ||
14 | pub struct CrateDependency { | ||
15 | pub krate: Crate, | ||
16 | pub name: Name, | ||
17 | } | ||
18 | |||
19 | impl Crate { | ||
20 | pub fn dependencies(&self, db: &impl HirDatabase) -> Vec<CrateDependency> { | ||
21 | self.dependencies_impl(db) | ||
22 | } | ||
23 | pub fn root_module(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> { | ||
24 | self.root_module_impl(db) | ||
25 | } | ||
26 | } | ||