aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-11-27 18:58:44 +0000
committerAleksey Kladov <[email protected]>2018-11-27 18:58:44 +0000
commitf4d0cb64fc8b3010bdc4b168a2fa6d96a6cf90b1 (patch)
tree8e0ede40dff7402ebc18328db24fa195c9faf2c3
parentd659b7a2f03788eb0f4f15e3730bbf65a18ed818 (diff)
rename descriptorsdb -> hirdb
-rw-r--r--crates/ra_analysis/src/db.rs2
-rw-r--r--crates/ra_analysis/src/hir/function/imp.rs6
-rw-r--r--crates/ra_analysis/src/hir/mod.rs4
-rw-r--r--crates/ra_analysis/src/hir/module/imp.rs10
-rw-r--r--crates/ra_analysis/src/hir/module/mod.rs23
-rw-r--r--crates/ra_analysis/src/hir/module/nameres.rs16
-rw-r--r--crates/ra_analysis/src/imp.rs2
7 files changed, 30 insertions, 33 deletions
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! {
122 fn file_symbols() for FileSymbolsQuery; 122 fn file_symbols() for FileSymbolsQuery;
123 fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery; 123 fn resolve_syntax_ptr() for ResolveSyntaxPtrQuery;
124 } 124 }
125 impl hir::DescriptorDatabase { 125 impl hir::HirDatabase {
126 fn module_tree() for hir::ModuleTreeQuery; 126 fn module_tree() for hir::ModuleTreeQuery;
127 fn fn_scopes() for hir::FnScopesQuery; 127 fn fn_scopes() for hir::FnScopesQuery;
128 fn _file_items() for hir::FileItemsQuery; 128 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};
4 4
5use crate::hir::{ 5use crate::hir::{
6 function::{FnId, FnScopes}, 6 function::{FnId, FnScopes},
7 DescriptorDatabase, 7 HirDatabase,
8}; 8};
9 9
10/// Resolve `FnId` to the corresponding `SyntaxNode` 10/// Resolve `FnId` to the corresponding `SyntaxNode`
11pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { 11pub(crate) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode {
12 let ptr = db.id_maps().fn_ptr(fn_id); 12 let ptr = db.id_maps().fn_ptr(fn_id);
13 let syntax = db.resolve_syntax_ptr(ptr); 13 let syntax = db.resolve_syntax_ptr(ptr);
14 FnDef::cast(syntax.borrowed()).unwrap().owned() 14 FnDef::cast(syntax.borrowed()).unwrap().owned()
15} 15}
16 16
17pub(crate) fn fn_scopes(db: &impl DescriptorDatabase, fn_id: FnId) -> Arc<FnScopes> { 17pub(crate) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> {
18 let syntax = db._fn_syntax(fn_id); 18 let syntax = db._fn_syntax(fn_id);
19 let res = FnScopes::new(syntax.borrowed()); 19 let res = FnScopes::new(syntax.borrowed());
20 Arc::new(res) 20 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};
34pub(crate) use self::module::nameres::FileItemId; 34pub(crate) use self::module::nameres::FileItemId;
35 35
36salsa::query_group! { 36salsa::query_group! {
37 pub(crate) trait DescriptorDatabase: SyntaxDatabase + IdDatabase { 37pub(crate) trait HirDatabase: SyntaxDatabase + IdDatabase {
38 fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> { 38 fn fn_scopes(fn_id: FnId) -> Arc<FnScopes> {
39 type FnScopesQuery; 39 type FnScopesQuery;
40 use fn function::imp::fn_scopes; 40 use fn function::imp::fn_scopes;
@@ -83,7 +83,7 @@ pub(crate) enum Def {
83} 83}
84 84
85impl DefId { 85impl DefId {
86 pub(crate) fn resolve(self, db: &impl DescriptorDatabase) -> Cancelable<Def> { 86 pub(crate) fn resolve(self, db: &impl HirDatabase) -> Cancelable<Def> {
87 let loc = db.id_maps().def_loc(self); 87 let loc = db.id_maps().def_loc(self);
88 let res = match loc { 88 let res = match loc {
89 DefLoc::Module { id, source_root } => { 89 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};
9 9
10use crate::{ 10use crate::{
11 db, 11 db,
12 hir::DescriptorDatabase, 12 hir::HirDatabase,
13 input::{SourceRoot, SourceRootId}, 13 input::{SourceRoot, SourceRootId},
14 Cancelable, FileId, FileResolverImp, 14 Cancelable, FileId, FileResolverImp,
15}; 15};
@@ -35,7 +35,7 @@ impl Submodule {
35} 35}
36 36
37pub(crate) fn submodules( 37pub(crate) fn submodules(
38 db: &impl DescriptorDatabase, 38 db: &impl HirDatabase,
39 source: ModuleSource, 39 source: ModuleSource,
40) -> Cancelable<Arc<Vec<Submodule>>> { 40) -> Cancelable<Arc<Vec<Submodule>>> {
41 db::check_canceled(db)?; 41 db::check_canceled(db)?;
@@ -82,7 +82,7 @@ pub(crate) fn modules<'a>(
82} 82}
83 83
84pub(crate) fn module_tree( 84pub(crate) fn module_tree(
85 db: &impl DescriptorDatabase, 85 db: &impl HirDatabase,
86 source_root: SourceRootId, 86 source_root: SourceRootId,
87) -> Cancelable<Arc<ModuleTree>> { 87) -> Cancelable<Arc<ModuleTree>> {
88 db::check_canceled(db)?; 88 db::check_canceled(db)?;
@@ -91,7 +91,7 @@ pub(crate) fn module_tree(
91} 91}
92 92
93fn create_module_tree<'a>( 93fn create_module_tree<'a>(
94 db: &impl DescriptorDatabase, 94 db: &impl HirDatabase,
95 source_root: SourceRootId, 95 source_root: SourceRootId,
96) -> Cancelable<ModuleTree> { 96) -> Cancelable<ModuleTree> {
97 let mut tree = ModuleTree::default(); 97 let mut tree = ModuleTree::default();
@@ -121,7 +121,7 @@ fn create_module_tree<'a>(
121} 121}
122 122
123fn build_subtree( 123fn build_subtree(
124 db: &impl DescriptorDatabase, 124 db: &impl HirDatabase,
125 source_root: &SourceRoot, 125 source_root: &SourceRoot,
126 tree: &mut ModuleTree, 126 tree: &mut ModuleTree,
127 visited: &mut FxHashSet<ModuleSource>, 127 visited: &mut FxHashSet<ModuleSource>,
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;
14 14
15use crate::{ 15use crate::{
16 db::SyntaxDatabase, syntax_ptr::SyntaxPtr, FileId, FilePosition, Cancelable, 16 db::SyntaxDatabase, syntax_ptr::SyntaxPtr, FileId, FilePosition, Cancelable,
17 hir::{Path, PathKind, DescriptorDatabase}, 17 hir::{Path, PathKind, HirDatabase},
18 input::SourceRootId, 18 input::SourceRootId,
19 arena::{Arena, Id}, 19 arena::{Arena, Id},
20 loc2id::{DefLoc, DefId}, 20 loc2id::{DefLoc, DefId},
@@ -36,7 +36,7 @@ impl ModuleDescriptor {
36 /// lossy transformation: in general, a single source might correspond to 36 /// lossy transformation: in general, a single source might correspond to
37 /// several modules. 37 /// several modules.
38 pub fn guess_from_file_id( 38 pub fn guess_from_file_id(
39 db: &impl DescriptorDatabase, 39 db: &impl HirDatabase,
40 file_id: FileId, 40 file_id: FileId,
41 ) -> Cancelable<Option<ModuleDescriptor>> { 41 ) -> Cancelable<Option<ModuleDescriptor>> {
42 ModuleDescriptor::guess_from_source(db, file_id, ModuleSource::SourceFile(file_id)) 42 ModuleDescriptor::guess_from_source(db, file_id, ModuleSource::SourceFile(file_id))
@@ -46,7 +46,7 @@ impl ModuleDescriptor {
46 /// is inherently lossy transformation: in general, a single source might 46 /// is inherently lossy transformation: in general, a single source might
47 /// correspond to several modules. 47 /// correspond to several modules.
48 pub fn guess_from_position( 48 pub fn guess_from_position(
49 db: &impl DescriptorDatabase, 49 db: &impl HirDatabase,
50 position: FilePosition, 50 position: FilePosition,
51 ) -> Cancelable<Option<ModuleDescriptor>> { 51 ) -> Cancelable<Option<ModuleDescriptor>> {
52 let file = db.file_syntax(position.file_id); 52 let file = db.file_syntax(position.file_id);
@@ -59,7 +59,7 @@ impl ModuleDescriptor {
59 } 59 }
60 60
61 fn guess_from_source( 61 fn guess_from_source(
62 db: &impl DescriptorDatabase, 62 db: &impl HirDatabase,
63 file_id: FileId, 63 file_id: FileId,
64 module_source: ModuleSource, 64 module_source: ModuleSource,
65 ) -> Cancelable<Option<ModuleDescriptor>> { 65 ) -> Cancelable<Option<ModuleDescriptor>> {
@@ -78,7 +78,7 @@ impl ModuleDescriptor {
78 } 78 }
79 79
80 pub(super) fn new( 80 pub(super) fn new(
81 db: &impl DescriptorDatabase, 81 db: &impl HirDatabase,
82 source_root_id: SourceRootId, 82 source_root_id: SourceRootId,
83 module_id: ModuleId, 83 module_id: ModuleId,
84 ) -> Cancelable<ModuleDescriptor> { 84 ) -> Cancelable<ModuleDescriptor> {
@@ -93,10 +93,7 @@ impl ModuleDescriptor {
93 93
94 /// Returns `mod foo;` or `mod foo {}` node whihc declared this module. 94 /// Returns `mod foo;` or `mod foo {}` node whihc declared this module.
95 /// Returns `None` for the root module 95 /// Returns `None` for the root module
96 pub fn parent_link_source( 96 pub fn parent_link_source(&self, db: &impl HirDatabase) -> Option<(FileId, ast::ModuleNode)> {
97 &self,
98 db: &impl DescriptorDatabase,
99 ) -> Option<(FileId, ast::ModuleNode)> {
100 let link = self.module_id.parent_link(&self.tree)?; 97 let link = self.module_id.parent_link(&self.tree)?;
101 let file_id = link.owner(&self.tree).source(&self.tree).file_id(); 98 let file_id = link.owner(&self.tree).source(&self.tree).file_id();
102 let src = link.bind_source(&self.tree, db); 99 let src = link.bind_source(&self.tree, db);
@@ -132,7 +129,7 @@ impl ModuleDescriptor {
132 Some(link.name(&self.tree)) 129 Some(link.name(&self.tree))
133 } 130 }
134 131
135 pub fn def_id(&self, db: &impl DescriptorDatabase) -> DefId { 132 pub fn def_id(&self, db: &impl HirDatabase) -> DefId {
136 let def_loc = DefLoc::Module { 133 let def_loc = DefLoc::Module {
137 id: self.module_id, 134 id: self.module_id,
138 source_root: self.source_root_id, 135 source_root: self.source_root_id,
@@ -150,7 +147,7 @@ impl ModuleDescriptor {
150 } 147 }
151 148
152 /// Returns a `ModuleScope`: a set of items, visible in this module. 149 /// Returns a `ModuleScope`: a set of items, visible in this module.
153 pub(crate) fn scope(&self, db: &impl DescriptorDatabase) -> Cancelable<ModuleScope> { 150 pub(crate) fn scope(&self, db: &impl HirDatabase) -> Cancelable<ModuleScope> {
154 let item_map = db._item_map(self.source_root_id)?; 151 let item_map = db._item_map(self.source_root_id)?;
155 let res = item_map.per_module[&self.module_id].clone(); 152 let res = item_map.per_module[&self.module_id].clone();
156 Ok(res) 153 Ok(res)
@@ -158,7 +155,7 @@ impl ModuleDescriptor {
158 155
159 pub(crate) fn resolve_path( 156 pub(crate) fn resolve_path(
160 &self, 157 &self,
161 db: &impl DescriptorDatabase, 158 db: &impl HirDatabase,
162 path: Path, 159 path: Path,
163 ) -> Cancelable<Option<DefId>> { 160 ) -> Cancelable<Option<DefId>> {
164 let mut curr = match path.kind { 161 let mut curr = match path.kind {
@@ -180,7 +177,7 @@ impl ModuleDescriptor {
180 Ok(Some(curr)) 177 Ok(Some(curr))
181 } 178 }
182 179
183 pub fn problems(&self, db: &impl DescriptorDatabase) -> Vec<(SyntaxNode, Problem)> { 180 pub fn problems(&self, db: &impl HirDatabase) -> Vec<(SyntaxNode, Problem)> {
184 self.module_id.problems(&self.tree, db) 181 self.module_id.problems(&self.tree, db)
185 } 182 }
186} 183}
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::{
33 loc2id::{DefId, DefLoc}, 33 loc2id::{DefId, DefLoc},
34 hir::{ 34 hir::{
35 Path, PathKind, 35 Path, PathKind,
36 DescriptorDatabase, 36 HirDatabase,
37 module::{ModuleId, ModuleTree, ModuleSourceNode}, 37 module::{ModuleId, ModuleTree, ModuleSourceNode},
38 }, 38 },
39 input::SourceRootId, 39 input::SourceRootId,
@@ -71,7 +71,7 @@ impl Index<FileItemId> for FileItems {
71 } 71 }
72} 72}
73 73
74pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc<FileItems> { 74pub(crate) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<FileItems> {
75 let source_file = db.file_syntax(file_id); 75 let source_file = db.file_syntax(file_id);
76 let source_file = source_file.borrowed(); 76 let source_file = source_file.borrowed();
77 let mut res = FileItems::default(); 77 let mut res = FileItems::default();
@@ -87,7 +87,7 @@ pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc<F
87} 87}
88 88
89pub(crate) fn file_item( 89pub(crate) fn file_item(
90 db: &impl DescriptorDatabase, 90 db: &impl HirDatabase,
91 file_id: FileId, 91 file_id: FileId,
92 file_item_id: FileItemId, 92 file_item_id: FileItemId,
93) -> SyntaxNode { 93) -> SyntaxNode {
@@ -154,7 +154,7 @@ pub(crate) struct NamedImport {
154} 154}
155 155
156impl NamedImport { 156impl NamedImport {
157 pub(crate) fn range(&self, db: &impl DescriptorDatabase, file_id: FileId) -> TextRange { 157 pub(crate) fn range(&self, db: &impl HirDatabase, file_id: FileId) -> TextRange {
158 let syntax = db._file_item(file_id, self.file_item_id); 158 let syntax = db._file_item(file_id, self.file_item_id);
159 let offset = syntax.borrowed().range().start(); 159 let offset = syntax.borrowed().range().start();
160 self.relative_range + offset 160 self.relative_range + offset
@@ -168,7 +168,7 @@ enum ImportKind {
168} 168}
169 169
170pub(crate) fn input_module_items( 170pub(crate) fn input_module_items(
171 db: &impl DescriptorDatabase, 171 db: &impl HirDatabase,
172 source_root: SourceRootId, 172 source_root: SourceRootId,
173 module_id: ModuleId, 173 module_id: ModuleId,
174) -> Cancelable<Arc<InputModuleItems>> { 174) -> Cancelable<Arc<InputModuleItems>> {
@@ -193,7 +193,7 @@ pub(crate) fn input_module_items(
193} 193}
194 194
195pub(crate) fn item_map( 195pub(crate) fn item_map(
196 db: &impl DescriptorDatabase, 196 db: &impl HirDatabase,
197 source_root: SourceRootId, 197 source_root: SourceRootId,
198) -> Cancelable<Arc<ItemMap>> { 198) -> Cancelable<Arc<ItemMap>> {
199 let start = Instant::now(); 199 let start = Instant::now();
@@ -316,7 +316,7 @@ struct Resolver<'a, DB> {
316 316
317impl<'a, DB> Resolver<'a, DB> 317impl<'a, DB> Resolver<'a, DB>
318where 318where
319 DB: DescriptorDatabase, 319 DB: HirDatabase,
320{ 320{
321 fn resolve(&mut self) -> Cancelable<()> { 321 fn resolve(&mut self) -> Cancelable<()> {
322 for (&module_id, items) in self.input.iter() { 322 for (&module_id, items) in self.input.iter() {
@@ -447,7 +447,7 @@ mod tests {
447 use crate::{ 447 use crate::{
448 AnalysisChange, 448 AnalysisChange,
449 mock_analysis::{MockAnalysis, analysis_and_position}, 449 mock_analysis::{MockAnalysis, analysis_and_position},
450 hir::{DescriptorDatabase, module::ModuleDescriptor}, 450 hir::{HirDatabase, module::ModuleDescriptor},
451 input::FilesDatabase, 451 input::FilesDatabase,
452}; 452};
453 use super::*; 453 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::{
22 hir::{ 22 hir::{
23 function::{FnDescriptor, FnId}, 23 function::{FnDescriptor, FnId},
24 module::{ModuleDescriptor, Problem}, 24 module::{ModuleDescriptor, Problem},
25 DeclarationDescriptor, DescriptorDatabase, 25 DeclarationDescriptor, HirDatabase,
26 }, 26 },
27 input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE}, 27 input::{FilesDatabase, SourceRoot, SourceRootId, WORKSPACE},
28 symbol_index::SymbolIndex, 28 symbol_index::SymbolIndex,