rename descriptorsdb -> hirdb

This commit is contained in:
Aleksey Kladov 2018-11-27 21:58:44 +03:00
parent d659b7a2f0
commit f4d0cb64fc
7 changed files with 30 additions and 33 deletions

View File

@ -122,7 +122,7 @@ impl SyntaxDatabase {
fn file_symbols() for FileSymbolsQuery;
fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
}
impl hir::DescriptorDatabase {
impl hir::HirDatabase {
fn module_tree() for hir::ModuleTreeQuery;
fn fn_scopes() for hir::FnScopesQuery;
fn _file_items() for hir::FileItemsQuery;

View File

@ -4,17 +4,17 @@
use crate::hir::{
function::{FnId, FnScopes},
DescriptorDatabase,
HirDatabase,
};
/// Resolve `FnId` to the corresponding `SyntaxNode`
pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode {
pub(crate) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode {
let ptr = db.id_maps().fn_ptr(fn_id);
let syntax = db.resolve_syntax_ptr(ptr);
FnDef::cast(syntax.borrowed()).unwrap().owned()
}
pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> {
pub(crate) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> {
let syntax = db._fn_syntax(fn_id);
let res = FnScopes::new(syntax.borrowed());
Arc::new(res)

View File

@ -34,7 +34,7 @@
pub(crate) use self::module::nameres::FileItemId;
salsa::query_group! {
pub(crate) trait DescriptorDatabase: SyntaxDatabase + IdDatabase {
pub(crate) trait HirDatabase: SyntaxDatabase + IdDatabase {
fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
type FnScopesQuery;
use fn function::imp::fn_scopes;
@ -83,7 +83,7 @@ pub(crate) enum Def {
}
impl DefId {
pub(crate) fn resolve(self, db: &impl DescriptorDatabase) -> Cancelable<Def> {
pub(crate) fn resolve(self, db: &impl HirDatabase) -> Cancelable<Def> {
let loc = db.id_maps().def_loc(self);
let res = match loc {
DefLoc::Module { id, source_root } => {

View File

@ -9,7 +9,7 @@
use crate::{
db,
hir::DescriptorDatabase,
hir::HirDatabase,
input::{SourceRoot, SourceRootId},
Cancelable, FileId, FileResolverImp,
};
@ -35,7 +35,7 @@ fn name(&self) -> &SmolStr {
}
pub(crate) fn submodules(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source: ModuleSource,
) -> Cancelable<Arc<Vec<Submodule>>> {
db::check_canceled(db)?;
@ -82,7 +82,7 @@ pub(crate) fn modules<'a>(
}
pub(crate) fn module_tree(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source_root: SourceRootId,
) -> Cancelable<Arc<ModuleTree>> {
db::check_canceled(db)?;
@ -91,7 +91,7 @@ pub(crate) fn module_tree(
}
fn create_module_tree<'a>(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source_root: SourceRootId,
) -> Cancelable<ModuleTree> {
let mut tree = ModuleTree::default();
@ -121,7 +121,7 @@ fn create_module_tree<'a>(
}
fn build_subtree(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source_root: &SourceRoot,
tree: &mut ModuleTree,
visited: &mut FxHashSet<ModuleSource>,

View File

@ -14,7 +14,7 @@
use crate::{
db::SyntaxDatabase, syntax_ptr::SyntaxPtr, FileId, FilePosition, Cancelable,
hir::{Path, PathKind, DescriptorDatabase},
hir::{Path, PathKind, HirDatabase},
input::SourceRootId,
arena::{Arena, Id},
loc2id::{DefLoc, DefId},
@ -36,7 +36,7 @@ impl ModuleDescriptor {
/// lossy transformation: in general, a single source might correspond to
/// several modules.
pub fn guess_from_file_id(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
file_id: FileId,
) -> Cancelable<Option<ModuleDescriptor>> {
ModuleDescriptor::guess_from_source(db, file_id, ModuleSource::SourceFile(file_id))
@ -46,7 +46,7 @@ pub fn guess_from_file_id(
/// is inherently lossy transformation: in general, a single source might
/// correspond to several modules.
pub fn guess_from_position(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
position: FilePosition,
) -> Cancelable<Option<ModuleDescriptor>> {
let file = db.file_syntax(position.file_id);
@ -59,7 +59,7 @@ pub fn guess_from_position(
}
fn guess_from_source(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
file_id: FileId,
module_source: ModuleSource,
) -> Cancelable<Option<ModuleDescriptor>> {
@ -78,7 +78,7 @@ fn guess_from_source(
}
pub(super) fn new(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source_root_id: SourceRootId,
module_id: ModuleId,
) -> Cancelable<ModuleDescriptor> {
@ -93,10 +93,7 @@ pub(super) fn new(
/// Returns `mod foo;` or `mod foo {}` node whihc declared this module.
/// Returns `None` for the root module
pub fn parent_link_source(
&self,
db: &impl DescriptorDatabase,
) -> Option<(FileId, ast::ModuleNode)> {
pub fn parent_link_source(&self, db: &impl HirDatabase) -> Option<(FileId, ast::ModuleNode)> {
let link = self.module_id.parent_link(&self.tree)?;
let file_id = link.owner(&self.tree).source(&self.tree).file_id();
let src = link.bind_source(&self.tree, db);
@ -132,7 +129,7 @@ pub fn name(&self) -> Option<SmolStr> {
Some(link.name(&self.tree))
}
pub fn def_id(&self, db: &impl DescriptorDatabase) -> DefId {
pub fn def_id(&self, db: &impl HirDatabase) -> DefId {
let def_loc = DefLoc::Module {
id: self.module_id,
source_root: self.source_root_id,
@ -150,7 +147,7 @@ pub fn child(&self, name: &str) -> Option<ModuleDescriptor> {
}
/// Returns a `ModuleScope`: a set of items, visible in this module.
pub(crate) fn scope(&self, db: &impl DescriptorDatabase) -> Cancelable<ModuleScope> {
pub(crate) fn scope(&self, db: &impl HirDatabase) -> Cancelable<ModuleScope> {
let item_map = db._item_map(self.source_root_id)?;
let res = item_map.per_module[&self.module_id].clone();
Ok(res)
@ -158,7 +155,7 @@ pub(crate) fn scope(&self, db: &impl DescriptorDatabase) -> Cancelable<ModuleSco
pub(crate) fn resolve_path(
&self,
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
path: Path,
) -> Cancelable<Option<DefId>> {
let mut curr = match path.kind {
@ -180,7 +177,7 @@ pub(crate) fn resolve_path(
Ok(Some(curr))
}
pub fn problems(&self, db: &impl DescriptorDatabase) -> Vec<(SyntaxNode, Problem)> {
pub fn problems(&self, db: &impl HirDatabase) -> Vec<(SyntaxNode, Problem)> {
self.module_id.problems(&self.tree, db)
}
}

View File

@ -33,7 +33,7 @@
loc2id::{DefId, DefLoc},
hir::{
Path, PathKind,
DescriptorDatabase,
HirDatabase,
module::{ModuleId, ModuleTree, ModuleSourceNode},
},
input::SourceRootId,
@ -71,7 +71,7 @@ fn index(&self, idx: FileItemId) -> &SyntaxNode {
}
}
pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc<FileItems> {
pub(crate) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<FileItems> {
let source_file = db.file_syntax(file_id);
let source_file = source_file.borrowed();
let mut res = FileItems::default();
@ -87,7 +87,7 @@ pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc<F
}
pub(crate) fn file_item(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
file_id: FileId,
file_item_id: FileItemId,
) -> SyntaxNode {
@ -154,7 +154,7 @@ pub(crate) struct NamedImport {
}
impl NamedImport {
pub(crate) fn range(&self, db: &impl DescriptorDatabase, file_id: FileId) -> TextRange {
pub(crate) fn range(&self, db: &impl HirDatabase, file_id: FileId) -> TextRange {
let syntax = db._file_item(file_id, self.file_item_id);
let offset = syntax.borrowed().range().start();
self.relative_range + offset
@ -168,7 +168,7 @@ enum ImportKind {
}
pub(crate) fn input_module_items(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source_root: SourceRootId,
module_id: ModuleId,
) -> Cancelable<Arc<InputModuleItems>> {
@ -193,7 +193,7 @@ pub(crate) fn input_module_items(
}
pub(crate) fn item_map(
db: &impl DescriptorDatabase,
db: &impl HirDatabase,
source_root: SourceRootId,
) -> Cancelable<Arc<ItemMap>> {
let start = Instant::now();
@ -316,7 +316,7 @@ struct Resolver<'a, DB> {
impl<'a, DB> Resolver<'a, DB>
where
DB: DescriptorDatabase,
DB: HirDatabase,
{
fn resolve(&mut self) -> Cancelable<()> {
for (&module_id, items) in self.input.iter() {
@ -447,7 +447,7 @@ mod tests {
use crate::{
AnalysisChange,
mock_analysis::{MockAnalysis, analysis_and_position},
hir::{DescriptorDatabase, module::ModuleDescriptor},
hir::{HirDatabase, module::ModuleDescriptor},
input::FilesDatabase,
};
use super::*;

View File

@ -22,7 +22,7 @@
hir::{
function::{FnDescriptor, FnId},
module::{ModuleDescriptor, Problem},
DeclarationDescriptor, DescriptorDatabase,
DeclarationDescriptor, HirDatabase,
},
input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE},
symbol_index::SymbolIndex,