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