mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 06:11:35 +00:00
Add ModuleScope as a query
This is a first step towards queryifing completion and resolve. Some code currently duplicates ra_editor: the plan is to move all completion from ra_editor, but it'll take more than one commit.
This commit is contained in:
parent
d10214581e
commit
fbbee53722
8 changed files with 223 additions and 22 deletions
|
@ -1,4 +1,5 @@
|
|||
mod imp;
|
||||
pub(crate) mod scope;
|
||||
|
||||
use std::sync::Arc;
|
||||
|
||||
|
@ -11,6 +12,8 @@ use crate::{
|
|||
input::SourceRootId,
|
||||
};
|
||||
|
||||
pub(crate) use self::scope::ModuleScope;
|
||||
|
||||
salsa::query_group! {
|
||||
pub(crate) trait ModulesDatabase: SyntaxDatabase {
|
||||
fn module_tree(source_root_id: SourceRootId) -> Cancelable<Arc<ModuleTree>> {
|
||||
|
@ -21,6 +24,10 @@ salsa::query_group! {
|
|||
type SubmodulesQuery;
|
||||
use fn imp::submodules;
|
||||
}
|
||||
fn module_scope(source_root_id: SourceRootId, module_id: ModuleId) -> Cancelable<Arc<ModuleScope>> {
|
||||
type ModuleScopeQuery;
|
||||
use fn imp::module_scope;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -78,6 +85,7 @@ impl ModuleId {
|
|||
while let Some(next) = curr.parent(tree) {
|
||||
curr = next;
|
||||
i += 1;
|
||||
// simplistic cycle detection
|
||||
if i > 100 {
|
||||
return self;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue