move crate to code_model_api

This commit is contained in:
Aleksey Kladov 2019-01-05 00:02:05 +03:00
parent eaf553dade
commit 9a820dc0ee
3 changed files with 34 additions and 21 deletions

View file

@ -0,0 +1,26 @@
use ra_db::{CrateId, Cancelable};
use crate::{Module, Name, db::HirDatabase};
/// hir::Crate describes a single crate. It's the main inteface with which
/// crate's dependencies interact. Mostly, it should be just a proxy for the
/// root module.
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
pub struct Crate {
pub(crate) crate_id: CrateId,
}
#[derive(Debug)]
pub struct CrateDependency {
pub krate: Crate,
pub name: Name,
}
impl Crate {
pub fn dependencies(&self, db: &impl HirDatabase) -> Vec<CrateDependency> {
self.dependencies_impl(db)
}
pub fn root_module(&self, db: &impl HirDatabase) -> Cancelable<Option<Module>> {
self.root_module_impl(db)
}
}