use ra_db::{Cancelable, SourceRootId, FileId};
use ra_syntax::{ast, SyntaxNode, AstNode, TreeArc};
use crate::{
Module, ModuleSource, Problem,
Crate, DefId, DefLoc, DefKind, Name, Path, PathKind, PerNs, Def,
module_tree::ModuleId,
nameres::ModuleScope,
db::HirDatabase,
};
impl Module {
pub(crate) fn new(def_id: DefId) -> Self {
crate::code_model_api::Module { def_id }
}
pub(crate) fn from_module_id(
db: &impl HirDatabase,
source_root_id: SourceRootId,
module_id: ModuleId,
) -> Self {
let module_tree = db.module_tree(source_root_id);
let def_loc = DefLoc {
kind: DefKind::Module,
source_root_id,
module_id,
source_item_id: module_id.source(&module_tree),
};
let def_id = def_loc.id(db);
Module::new(def_id)
}
pub(crate) fn name_impl(&self, db: &impl HirDatabase) -> Cancelable