mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-28 21:05:02 +00:00
Start code_model::Module
This commit is contained in:
parent
9a820dc0ee
commit
147b0f94e6
4 changed files with 83 additions and 7 deletions
|
@ -1,6 +1,6 @@
|
|||
use ra_db::{CrateId, Cancelable};
|
||||
|
||||
use crate::{Module, Name, db::HirDatabase};
|
||||
use crate::{Name, db::HirDatabase, DefId};
|
||||
|
||||
/// 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
|
||||
|
@ -24,3 +24,24 @@ impl Crate {
|
|||
self.root_module_impl(db)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Hash)]
|
||||
pub struct Module {
|
||||
pub(crate) def_id: DefId,
|
||||
}
|
||||
|
||||
impl Module {
|
||||
/// Returns the crate this module is part of.
|
||||
pub fn krate(&self, db: &impl HirDatabase) -> Cancelable<Option<Crate>> {
|
||||
self.krate_impl(db)
|
||||
}
|
||||
|
||||
pub fn crate_root(&self, db: &impl HirDatabase) -> Cancelable<Module> {
|
||||
self.crate_root_impl(db)
|
||||
}
|
||||
|
||||
/// Finds a child module with the specified name.
|
||||
pub fn child(&self, db: &impl HirDatabase, name: &Name) -> Cancelable<Option<Module>> {
|
||||
self.child_impl(db, name)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue