use module_for_source
This commit is contained in:
parent
cd878658d3
commit
88a15d10d5
3 changed files with 8 additions and 12 deletions
|
@ -11,7 +11,7 @@ use rustc_hash::{FxHashMap, FxHashSet};
|
|||
use crate::{
|
||||
db::{self, SyntaxDatabase},
|
||||
descriptors::function::FnScopes,
|
||||
descriptors::module::{ModuleId, ModuleScope, ModuleTree},
|
||||
descriptors::module::{ModuleId, ModuleScope, ModuleTree, ModuleSource},
|
||||
descriptors::DescriptorDatabase,
|
||||
input::FilesDatabase,
|
||||
Cancelable, FileId,
|
||||
|
@ -35,7 +35,7 @@ pub(crate) fn resolve_based_completion(
|
|||
let source_root_id = db.file_source_root(file_id);
|
||||
let file = db.file_syntax(file_id);
|
||||
let module_tree = db.module_tree(source_root_id)?;
|
||||
let module_id = match module_tree.any_module_for_file(file_id) {
|
||||
let module_id = match module_tree.any_module_for_source(ModuleSource::File(file_id)) {
|
||||
None => return Ok(None),
|
||||
Some(it) => it,
|
||||
};
|
||||
|
|
|
@ -34,12 +34,8 @@ impl ModuleTree {
|
|||
.collect()
|
||||
}
|
||||
|
||||
pub(crate) fn modules_for_file(&self, file_id: FileId) -> Vec<ModuleId> {
|
||||
self.modules_for_source(ModuleSource::File(file_id))
|
||||
}
|
||||
|
||||
pub(crate) fn any_module_for_file(&self, file_id: FileId) -> Option<ModuleId> {
|
||||
self.modules_for_file(file_id).pop()
|
||||
pub(crate) fn any_module_for_source(&self, source: ModuleSource) -> Option<ModuleId> {
|
||||
self.modules_for_source(source).pop()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ impl AnalysisImpl {
|
|||
let module_tree = self.module_tree(file_id)?;
|
||||
|
||||
let res = module_tree
|
||||
.modules_for_file(file_id)
|
||||
.modules_for_source(ModuleSource::File(file_id))
|
||||
.into_iter()
|
||||
.filter_map(|module_id| {
|
||||
let link = module_id.parent_link(&module_tree)?;
|
||||
|
@ -252,7 +252,7 @@ impl AnalysisImpl {
|
|||
let module_tree = self.module_tree(file_id)?;
|
||||
let crate_graph = self.db.crate_graph();
|
||||
let res = module_tree
|
||||
.modules_for_file(file_id)
|
||||
.modules_for_source(ModuleSource::File(file_id))
|
||||
.into_iter()
|
||||
.map(|it| it.root(&module_tree))
|
||||
.filter_map(|it| it.source(&module_tree).as_file())
|
||||
|
@ -376,7 +376,7 @@ impl AnalysisImpl {
|
|||
fix: None,
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
if let Some(m) = module_tree.any_module_for_file(file_id) {
|
||||
if let Some(m) = module_tree.any_module_for_source(ModuleSource::File(file_id)) {
|
||||
for (name_node, problem) in m.problems(&module_tree, &*self.db) {
|
||||
let diag = match problem {
|
||||
Problem::UnresolvedModule { candidate } => {
|
||||
|
@ -539,7 +539,7 @@ impl AnalysisImpl {
|
|||
Some(name) => name.text(),
|
||||
None => return Vec::new(),
|
||||
};
|
||||
let module_id = match module_tree.any_module_for_file(file_id) {
|
||||
let module_id = match module_tree.any_module_for_source(ModuleSource::File(file_id)) {
|
||||
Some(id) => id,
|
||||
None => return Vec::new(),
|
||||
};
|
||||
|
|
Loading…
Add table
Reference in a new issue