From f4d0cb64fc8b3010bdc4b168a2fa6d96a6cf90b1 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 27 Nov 2018 21:58:44 +0300 Subject: rename descriptorsdb -> hirdb --- crates/ra_analysis/src/db.rs | 2 +- crates/ra_analysis/src/hir/function/imp.rs | 6 +++--- crates/ra_analysis/src/hir/mod.rs | 4 ++-- crates/ra_analysis/src/hir/module/imp.rs | 10 +++++----- crates/ra_analysis/src/hir/module/mod.rs | 23 ++++++++++------------- crates/ra_analysis/src/hir/module/nameres.rs | 16 ++++++++-------- crates/ra_analysis/src/imp.rs | 2 +- 7 files changed, 30 insertions(+), 33 deletions(-) (limited to 'crates') diff --git a/crates/ra_analysis/src/db.rs b/crates/ra_analysis/src/db.rs index fa59b8b3e..b4fbbe7ad 100644 --- a/crates/ra_analysis/src/db.rs +++ b/crates/ra_analysis/src/db.rs @@ -122,7 +122,7 @@ salsa::database_storage! { 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; diff --git a/crates/ra_analysis/src/hir/function/imp.rs b/crates/ra_analysis/src/hir/function/imp.rs index cd573a47f..0d487d024 100644 --- a/crates/ra_analysis/src/hir/function/imp.rs +++ b/crates/ra_analysis/src/hir/function/imp.rs @@ -4,17 +4,17 @@ use ra_syntax::ast::{AstNode, FnDef, FnDefNode}; 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 { +pub(crate) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc { let syntax = db._fn_syntax(fn_id); let res = FnScopes::new(syntax.borrowed()); Arc::new(res) diff --git a/crates/ra_analysis/src/hir/mod.rs b/crates/ra_analysis/src/hir/mod.rs index 6bee2b5c4..232a8558b 100644 --- a/crates/ra_analysis/src/hir/mod.rs +++ b/crates/ra_analysis/src/hir/mod.rs @@ -34,7 +34,7 @@ pub(crate) use self::path::{Path, PathKind}; 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 { 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 { + pub(crate) fn resolve(self, db: &impl HirDatabase) -> Cancelable { let loc = db.id_maps().def_loc(self); let res = match loc { DefLoc::Module { id, source_root } => { diff --git a/crates/ra_analysis/src/hir/module/imp.rs b/crates/ra_analysis/src/hir/module/imp.rs index d8539ed85..062457ae0 100644 --- a/crates/ra_analysis/src/hir/module/imp.rs +++ b/crates/ra_analysis/src/hir/module/imp.rs @@ -9,7 +9,7 @@ use rustc_hash::{FxHashMap, FxHashSet}; use crate::{ db, - hir::DescriptorDatabase, + hir::HirDatabase, input::{SourceRoot, SourceRootId}, Cancelable, FileId, FileResolverImp, }; @@ -35,7 +35,7 @@ impl Submodule { } pub(crate) fn submodules( - db: &impl DescriptorDatabase, + db: &impl HirDatabase, source: ModuleSource, ) -> Cancelable>> { 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> { 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 { 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, diff --git a/crates/ra_analysis/src/hir/module/mod.rs b/crates/ra_analysis/src/hir/module/mod.rs index f374a079f..5bff11c90 100644 --- a/crates/ra_analysis/src/hir/module/mod.rs +++ b/crates/ra_analysis/src/hir/module/mod.rs @@ -14,7 +14,7 @@ use relative_path::RelativePathBuf; 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> { ModuleDescriptor::guess_from_source(db, file_id, ModuleSource::SourceFile(file_id)) @@ -46,7 +46,7 @@ impl ModuleDescriptor { /// 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> { let file = db.file_syntax(position.file_id); @@ -59,7 +59,7 @@ impl ModuleDescriptor { } fn guess_from_source( - db: &impl DescriptorDatabase, + db: &impl HirDatabase, file_id: FileId, module_source: ModuleSource, ) -> Cancelable> { @@ -78,7 +78,7 @@ impl ModuleDescriptor { } pub(super) fn new( - db: &impl DescriptorDatabase, + db: &impl HirDatabase, source_root_id: SourceRootId, module_id: ModuleId, ) -> Cancelable { @@ -93,10 +93,7 @@ impl ModuleDescriptor { /// 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 @@ impl ModuleDescriptor { 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 @@ impl ModuleDescriptor { } /// Returns a `ModuleScope`: a set of items, visible in this module. - pub(crate) fn scope(&self, db: &impl DescriptorDatabase) -> Cancelable { + pub(crate) fn scope(&self, db: &impl HirDatabase) -> Cancelable { 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 @@ impl ModuleDescriptor { pub(crate) fn resolve_path( &self, - db: &impl DescriptorDatabase, + db: &impl HirDatabase, path: Path, ) -> Cancelable> { let mut curr = match path.kind { @@ -180,7 +177,7 @@ impl ModuleDescriptor { 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) } } diff --git a/crates/ra_analysis/src/hir/module/nameres.rs b/crates/ra_analysis/src/hir/module/nameres.rs index 1ec85fbf2..bb5a888c8 100644 --- a/crates/ra_analysis/src/hir/module/nameres.rs +++ b/crates/ra_analysis/src/hir/module/nameres.rs @@ -33,7 +33,7 @@ use crate::{ loc2id::{DefId, DefLoc}, hir::{ Path, PathKind, - DescriptorDatabase, + HirDatabase, module::{ModuleId, ModuleTree, ModuleSourceNode}, }, input::SourceRootId, @@ -71,7 +71,7 @@ impl Index for FileItems { } } -pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc { +pub(crate) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc { 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 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> { @@ -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> { 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::*; diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 8d60f9af7..6dadc059f 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -22,7 +22,7 @@ use crate::{ hir::{ function::{FnDescriptor, FnId}, module::{ModuleDescriptor, Problem}, - DeclarationDescriptor, DescriptorDatabase, + DeclarationDescriptor, HirDatabase, }, input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, symbol_index::SymbolIndex, -- cgit v1.2.3