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:
Aleksey Kladov 2018-10-31 02:08:54 +03:00
parent d10214581e
commit fbbee53722
8 changed files with 223 additions and 22 deletions

View file

@ -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;
}