mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-29 13:25:09 +00:00
Turn ImplBlock into a copy type just containing IDs
This makes it more like the other code model types. Also make Module::definition_source/declaration_source return HirFileIds, to make them more like the other source functions.
This commit is contained in:
parent
6932b77093
commit
0242acae53
9 changed files with 65 additions and 77 deletions
|
@ -1,13 +1,12 @@
|
|||
use ra_db::FileId;
|
||||
use ra_syntax::{ast, SyntaxNode, TreeArc};
|
||||
|
||||
use crate::{
|
||||
Module, ModuleSource, Problem,
|
||||
Name,
|
||||
module_tree::ModuleId,
|
||||
impl_block::ImplId,
|
||||
nameres::{lower::ImportId},
|
||||
nameres::lower::ImportId,
|
||||
HirDatabase, PersistentHirDatabase,
|
||||
HirFileId
|
||||
};
|
||||
|
||||
impl Module {
|
||||
|
@ -24,22 +23,21 @@ impl Module {
|
|||
pub(crate) fn definition_source_impl(
|
||||
&self,
|
||||
db: &impl PersistentHirDatabase,
|
||||
) -> (FileId, ModuleSource) {
|
||||
) -> (HirFileId, ModuleSource) {
|
||||
let module_tree = db.module_tree(self.krate);
|
||||
let file_id = self.module_id.file_id(&module_tree);
|
||||
let decl_id = self.module_id.decl_id(&module_tree);
|
||||
let module_source = ModuleSource::new(db, file_id, decl_id);
|
||||
let file_id = file_id.as_original_file();
|
||||
(file_id, module_source)
|
||||
}
|
||||
|
||||
pub(crate) fn declaration_source_impl(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
) -> Option<(FileId, TreeArc<ast::Module>)> {
|
||||
) -> Option<(HirFileId, TreeArc<ast::Module>)> {
|
||||
let module_tree = db.module_tree(self.krate);
|
||||
let link = self.module_id.parent_link(&module_tree)?;
|
||||
let file_id = link.owner(&module_tree).file_id(&module_tree).as_original_file();
|
||||
let file_id = link.owner(&module_tree).file_id(&module_tree);
|
||||
let src = link.source(&module_tree, db);
|
||||
Some((file_id, src))
|
||||
}
|
||||
|
@ -54,16 +52,6 @@ impl Module {
|
|||
source_map.get(&source, import)
|
||||
}
|
||||
|
||||
pub(crate) fn impl_source_impl(
|
||||
&self,
|
||||
db: &impl HirDatabase,
|
||||
impl_id: ImplId,
|
||||
) -> TreeArc<ast::ImplBlock> {
|
||||
let source_map = db.impls_in_module_source_map(*self);
|
||||
let (_, source) = self.definition_source(db);
|
||||
source_map.get(&source, impl_id)
|
||||
}
|
||||
|
||||
pub(crate) fn crate_root_impl(&self, db: &impl PersistentHirDatabase) -> Module {
|
||||
let module_tree = db.module_tree(self.krate);
|
||||
let module_id = self.module_id.crate_root(&module_tree);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue