mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-26 20:09:19 +00:00
kill old module
This commit is contained in:
parent
3c2cb89087
commit
9cb02fd931
7 changed files with 67 additions and 234 deletions
|
@ -7,12 +7,14 @@ use ra_db::{LocationIntener, Cancelable, SourceRootId};
|
|||
|
||||
use crate::{
|
||||
DefId, DefLoc, DefKind, SourceItemId, SourceFileItems,
|
||||
Module, Function,
|
||||
Function,
|
||||
db::HirDatabase,
|
||||
type_ref::TypeRef,
|
||||
module::{ModuleSourceNode, ModuleId},
|
||||
};
|
||||
|
||||
use crate::code_model_api::Module;
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct ImplBlock {
|
||||
module_impl_blocks: Arc<ModuleImplBlocks>,
|
||||
|
@ -64,7 +66,7 @@ impl ImplData {
|
|||
) -> Self {
|
||||
let target_trait = node.target_type().map(TypeRef::from_ast);
|
||||
let target_type = TypeRef::from_ast_opt(node.target_type());
|
||||
let file_id = module.source().file_id();
|
||||
let module_loc = module.def_id.loc(db);
|
||||
let items = if let Some(item_list) = node.item_list() {
|
||||
item_list
|
||||
.impl_items()
|
||||
|
@ -75,14 +77,14 @@ impl ImplData {
|
|||
ast::ImplItem::TypeDef(..) => DefKind::Item,
|
||||
};
|
||||
let item_id = file_items.id_of_unchecked(item_node.syntax());
|
||||
let source_item_id = SourceItemId {
|
||||
file_id: module_loc.source_item_id.file_id,
|
||||
item_id: Some(item_id),
|
||||
};
|
||||
let def_loc = DefLoc {
|
||||
kind,
|
||||
source_root_id: module.source_root_id,
|
||||
module_id: module.module_id,
|
||||
source_item_id: SourceItemId {
|
||||
file_id,
|
||||
item_id: Some(item_id),
|
||||
},
|
||||
source_item_id,
|
||||
..module_loc
|
||||
};
|
||||
let def_id = def_loc.id(db);
|
||||
match item_node {
|
||||
|
@ -148,13 +150,13 @@ impl ModuleImplBlocks {
|
|||
}
|
||||
|
||||
fn collect(&mut self, db: &impl HirDatabase, module: Module) -> Cancelable<()> {
|
||||
let module_source_node = module.source().resolve(db);
|
||||
let module_source_node = module.source(db)?.resolve(db);
|
||||
let node = match &module_source_node {
|
||||
ModuleSourceNode::SourceFile(node) => node.borrowed().syntax(),
|
||||
ModuleSourceNode::Module(node) => node.borrowed().syntax(),
|
||||
};
|
||||
|
||||
let source_file_items = db.file_items(module.source().file_id());
|
||||
let source_file_items = db.file_items(module.source(db)?.file_id());
|
||||
|
||||
for impl_block_ast in node.children().filter_map(ast::ImplBlock::cast) {
|
||||
let impl_block = ImplData::from_ast(db, &source_file_items, &module, impl_block_ast);
|
||||
|
@ -174,7 +176,7 @@ pub(crate) fn impls_in_module(
|
|||
module_id: ModuleId,
|
||||
) -> Cancelable<Arc<ModuleImplBlocks>> {
|
||||
let mut result = ModuleImplBlocks::new();
|
||||
let module = Module::new(db, source_root_id, module_id)?;
|
||||
let module = Module::from_module_id(db, source_root_id, module_id)?;
|
||||
result.collect(db, module)?;
|
||||
Ok(Arc::new(result))
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue