aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_hir
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_hir')
-rw-r--r--crates/ra_hir/src/code_model_api.rs18
-rw-r--r--crates/ra_hir/src/code_model_impl/function.rs4
-rw-r--r--crates/ra_hir/src/code_model_impl/module.rs6
-rw-r--r--crates/ra_hir/src/db.rs6
-rw-r--r--crates/ra_hir/src/ids.rs10
-rw-r--r--crates/ra_hir/src/macros.rs6
-rw-r--r--crates/ra_hir/src/module_tree.rs6
-rw-r--r--crates/ra_hir/src/query_definitions.rs4
8 files changed, 30 insertions, 30 deletions
diff --git a/crates/ra_hir/src/code_model_api.rs b/crates/ra_hir/src/code_model_api.rs
index 8ec6b9b2b..098c7f40b 100644
--- a/crates/ra_hir/src/code_model_api.rs
+++ b/crates/ra_hir/src/code_model_api.rs
@@ -2,7 +2,7 @@ use std::sync::Arc;
2 2
3use relative_path::RelativePathBuf; 3use relative_path::RelativePathBuf;
4use ra_db::{CrateId, Cancelable, FileId}; 4use ra_db::{CrateId, Cancelable, FileId};
5use ra_syntax::{ast, TreePtr, SyntaxNode, AstNode}; 5use ra_syntax::{ast, TreeArc, SyntaxNode, AstNode};
6 6
7use crate::{ 7use crate::{
8 Name, DefId, Path, PerNs, ScopesWithSyntaxMapping, Ty, HirFileId, 8 Name, DefId, Path, PerNs, ScopesWithSyntaxMapping, Ty, HirFileId,
@@ -55,8 +55,8 @@ pub struct Module {
55} 55}
56 56
57pub enum ModuleSource { 57pub enum ModuleSource {
58 SourceFile(TreePtr<ast::SourceFile>), 58 SourceFile(TreeArc<ast::SourceFile>),
59 Module(TreePtr<ast::Module>), 59 Module(TreeArc<ast::Module>),
60} 60}
61 61
62#[derive(Clone, Debug, Hash, PartialEq, Eq)] 62#[derive(Clone, Debug, Hash, PartialEq, Eq)]
@@ -86,7 +86,7 @@ impl Module {
86 pub fn declaration_source( 86 pub fn declaration_source(
87 &self, 87 &self,
88 db: &impl HirDatabase, 88 db: &impl HirDatabase,
89 ) -> Cancelable<Option<(FileId, TreePtr<ast::Module>)>> { 89 ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
90 self.declaration_source_impl(db) 90 self.declaration_source_impl(db)
91 } 91 }
92 92
@@ -134,7 +134,7 @@ impl Module {
134 pub fn problems( 134 pub fn problems(
135 &self, 135 &self,
136 db: &impl HirDatabase, 136 db: &impl HirDatabase,
137 ) -> Cancelable<Vec<(TreePtr<SyntaxNode>, Problem)>> { 137 ) -> Cancelable<Vec<(TreeArc<SyntaxNode>, Problem)>> {
138 self.problems_impl(db) 138 self.problems_impl(db)
139 } 139 }
140} 140}
@@ -185,7 +185,7 @@ impl Struct {
185 pub fn source( 185 pub fn source(
186 &self, 186 &self,
187 db: &impl HirDatabase, 187 db: &impl HirDatabase,
188 ) -> Cancelable<(HirFileId, TreePtr<ast::StructDef>)> { 188 ) -> Cancelable<(HirFileId, TreeArc<ast::StructDef>)> {
189 let (file_id, syntax) = self.def_id.source(db); 189 let (file_id, syntax) = self.def_id.source(db);
190 Ok(( 190 Ok((
191 file_id, 191 file_id,
@@ -218,7 +218,7 @@ impl Enum {
218 Ok(db.enum_data(self.def_id)?.variants.clone()) 218 Ok(db.enum_data(self.def_id)?.variants.clone())
219 } 219 }
220 220
221 pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreePtr<ast::EnumDef>)> { 221 pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::EnumDef>)> {
222 let (file_id, syntax) = self.def_id.source(db); 222 let (file_id, syntax) = self.def_id.source(db);
223 Ok(( 223 Ok((
224 file_id, 224 file_id,
@@ -258,7 +258,7 @@ impl EnumVariant {
258 pub fn source( 258 pub fn source(
259 &self, 259 &self,
260 db: &impl HirDatabase, 260 db: &impl HirDatabase,
261 ) -> Cancelable<(HirFileId, TreePtr<ast::EnumVariant>)> { 261 ) -> Cancelable<(HirFileId, TreeArc<ast::EnumVariant>)> {
262 let (file_id, syntax) = self.def_id.source(db); 262 let (file_id, syntax) = self.def_id.source(db);
263 Ok(( 263 Ok((
264 file_id, 264 file_id,
@@ -303,7 +303,7 @@ impl Function {
303 self.def_id 303 self.def_id
304 } 304 }
305 305
306 pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreePtr<ast::FnDef>)> { 306 pub fn source(&self, db: &impl HirDatabase) -> Cancelable<(HirFileId, TreeArc<ast::FnDef>)> {
307 Ok(self.source_impl(db)) 307 Ok(self.source_impl(db))
308 } 308 }
309 309
diff --git a/crates/ra_hir/src/code_model_impl/function.rs b/crates/ra_hir/src/code_model_impl/function.rs
index 009175bab..daf49e791 100644
--- a/crates/ra_hir/src/code_model_impl/function.rs
+++ b/crates/ra_hir/src/code_model_impl/function.rs
@@ -4,7 +4,7 @@ use std::sync::Arc;
4 4
5use ra_db::Cancelable; 5use ra_db::Cancelable;
6use ra_syntax::{ 6use ra_syntax::{
7 TreePtr, 7 TreeArc,
8 ast::{self, AstNode, NameOwner}, 8 ast::{self, AstNode, NameOwner},
9}; 9};
10 10
@@ -22,7 +22,7 @@ impl Function {
22 Function { def_id } 22 Function { def_id }
23 } 23 }
24 24
25 pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, TreePtr<ast::FnDef>) { 25 pub(crate) fn source_impl(&self, db: &impl HirDatabase) -> (HirFileId, TreeArc<ast::FnDef>) {
26 let def_loc = self.def_id.loc(db); 26 let def_loc = self.def_id.loc(db);
27 assert!(def_loc.kind == DefKind::Function); 27 assert!(def_loc.kind == DefKind::Function);
28 let syntax = db.file_item(def_loc.source_item_id); 28 let syntax = db.file_item(def_loc.source_item_id);
diff --git a/crates/ra_hir/src/code_model_impl/module.rs b/crates/ra_hir/src/code_model_impl/module.rs
index 878dc37c8..e9ff06dc8 100644
--- a/crates/ra_hir/src/code_model_impl/module.rs
+++ b/crates/ra_hir/src/code_model_impl/module.rs
@@ -1,5 +1,5 @@
1use ra_db::{Cancelable, SourceRootId, FileId}; 1use ra_db::{Cancelable, SourceRootId, FileId};
2use ra_syntax::{ast, SyntaxNode, AstNode, TreePtr}; 2use ra_syntax::{ast, SyntaxNode, AstNode, TreeArc};
3 3
4use crate::{ 4use crate::{
5 Module, ModuleSource, Problem, 5 Module, ModuleSource, Problem,
@@ -57,7 +57,7 @@ impl Module {
57 pub fn declaration_source_impl( 57 pub fn declaration_source_impl(
58 &self, 58 &self,
59 db: &impl HirDatabase, 59 db: &impl HirDatabase,
60 ) -> Cancelable<Option<(FileId, TreePtr<ast::Module>)>> { 60 ) -> Cancelable<Option<(FileId, TreeArc<ast::Module>)>> {
61 let loc = self.def_id.loc(db); 61 let loc = self.def_id.loc(db);
62 let module_tree = db.module_tree(loc.source_root_id)?; 62 let module_tree = db.module_tree(loc.source_root_id)?;
63 let link = ctry!(loc.module_id.parent_link(&module_tree)); 63 let link = ctry!(loc.module_id.parent_link(&module_tree));
@@ -173,7 +173,7 @@ impl Module {
173 pub fn problems_impl( 173 pub fn problems_impl(
174 &self, 174 &self,
175 db: &impl HirDatabase, 175 db: &impl HirDatabase,
176 ) -> Cancelable<Vec<(TreePtr<SyntaxNode>, Problem)>> { 176 ) -> Cancelable<Vec<(TreeArc<SyntaxNode>, Problem)>> {
177 let loc = self.def_id.loc(db); 177 let loc = self.def_id.loc(db);
178 let module_tree = db.module_tree(loc.source_root_id)?; 178 let module_tree = db.module_tree(loc.source_root_id)?;
179 Ok(loc.module_id.problems(&module_tree, db)) 179 Ok(loc.module_id.problems(&module_tree, db))
diff --git a/crates/ra_hir/src/db.rs b/crates/ra_hir/src/db.rs
index 9a6ef8083..a11c73db0 100644
--- a/crates/ra_hir/src/db.rs
+++ b/crates/ra_hir/src/db.rs
@@ -1,6 +1,6 @@
1use std::sync::Arc; 1use std::sync::Arc;
2 2
3use ra_syntax::{SyntaxNode, TreePtr, SourceFile}; 3use ra_syntax::{SyntaxNode, TreeArc, SourceFile};
4use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable}; 4use ra_db::{SourceRootId, LocationIntener, SyntaxDatabase, Cancelable};
5 5
6use crate::{ 6use crate::{
@@ -22,7 +22,7 @@ pub trait HirDatabase: SyntaxDatabase
22 + AsRef<LocationIntener<DefLoc, DefId>> 22 + AsRef<LocationIntener<DefLoc, DefId>>
23 + AsRef<LocationIntener<MacroCallLoc, MacroCallId>> 23 + AsRef<LocationIntener<MacroCallLoc, MacroCallId>>
24{ 24{
25 fn hir_source_file(file_id: HirFileId) -> TreePtr<SourceFile> { 25 fn hir_source_file(file_id: HirFileId) -> TreeArc<SourceFile> {
26 type HirSourceFileQuery; 26 type HirSourceFileQuery;
27 use fn HirFileId::hir_source_file; 27 use fn HirFileId::hir_source_file;
28 } 28 }
@@ -72,7 +72,7 @@ pub trait HirDatabase: SyntaxDatabase
72 use fn query_definitions::file_items; 72 use fn query_definitions::file_items;
73 } 73 }
74 74
75 fn file_item(source_item_id: SourceItemId) -> TreePtr<SyntaxNode> { 75 fn file_item(source_item_id: SourceItemId) -> TreeArc<SyntaxNode> {
76 type FileItemQuery; 76 type FileItemQuery;
77 use fn query_definitions::file_item; 77 use fn query_definitions::file_item;
78 } 78 }
diff --git a/crates/ra_hir/src/ids.rs b/crates/ra_hir/src/ids.rs
index c75ef4ae7..0805fd3db 100644
--- a/crates/ra_hir/src/ids.rs
+++ b/crates/ra_hir/src/ids.rs
@@ -1,5 +1,5 @@
1use ra_db::{SourceRootId, LocationIntener, Cancelable, FileId}; 1use ra_db::{SourceRootId, LocationIntener, Cancelable, FileId};
2use ra_syntax::{TreePtr, SyntaxKind, SyntaxNode, SourceFile, AstNode, ast}; 2use ra_syntax::{TreeArc, SyntaxKind, SyntaxNode, SourceFile, AstNode, ast};
3use ra_arena::{Arena, RawId, impl_arena_id}; 3use ra_arena::{Arena, RawId, impl_arena_id};
4 4
5use crate::{ 5use crate::{
@@ -61,7 +61,7 @@ impl HirFileId {
61 pub(crate) fn hir_source_file( 61 pub(crate) fn hir_source_file(
62 db: &impl HirDatabase, 62 db: &impl HirDatabase,
63 file_id: HirFileId, 63 file_id: HirFileId,
64 ) -> TreePtr<SourceFile> { 64 ) -> TreeArc<SourceFile> {
65 match file_id.0 { 65 match file_id.0 {
66 HirFileIdRepr::File(file_id) => db.source_file(file_id), 66 HirFileIdRepr::File(file_id) => db.source_file(file_id),
67 HirFileIdRepr::Macro(m) => { 67 HirFileIdRepr::Macro(m) => {
@@ -179,7 +179,7 @@ impl DefId {
179 Ok(res) 179 Ok(res)
180 } 180 }
181 181
182 pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreePtr<SyntaxNode>) { 182 pub(crate) fn source(self, db: &impl HirDatabase) -> (HirFileId, TreeArc<SyntaxNode>) {
183 let loc = self.loc(db); 183 let loc = self.loc(db);
184 let syntax = db.file_item(loc.source_item_id); 184 let syntax = db.file_item(loc.source_item_id);
185 (loc.source_item_id.file_id, syntax) 185 (loc.source_item_id.file_id, syntax)
@@ -244,7 +244,7 @@ pub struct SourceItemId {
244#[derive(Debug, PartialEq, Eq)] 244#[derive(Debug, PartialEq, Eq)]
245pub struct SourceFileItems { 245pub struct SourceFileItems {
246 file_id: HirFileId, 246 file_id: HirFileId,
247 arena: Arena<SourceFileItemId, TreePtr<SyntaxNode>>, 247 arena: Arena<SourceFileItemId, TreeArc<SyntaxNode>>,
248} 248}
249 249
250impl SourceFileItems { 250impl SourceFileItems {
@@ -273,7 +273,7 @@ impl SourceFileItems {
273 }) 273 })
274 } 274 }
275 275
276 fn alloc(&mut self, item: TreePtr<SyntaxNode>) -> SourceFileItemId { 276 fn alloc(&mut self, item: TreeArc<SyntaxNode>) -> SourceFileItemId {
277 self.arena.alloc(item) 277 self.arena.alloc(item)
278 } 278 }
279 pub(crate) fn id_of(&self, file_id: HirFileId, item: &SyntaxNode) -> SourceFileItemId { 279 pub(crate) fn id_of(&self, file_id: HirFileId, item: &SyntaxNode) -> SourceFileItemId {
diff --git a/crates/ra_hir/src/macros.rs b/crates/ra_hir/src/macros.rs
index e455b2ad5..220bee94e 100644
--- a/crates/ra_hir/src/macros.rs
+++ b/crates/ra_hir/src/macros.rs
@@ -11,7 +11,7 @@ use std::sync::Arc;
11 11
12use ra_db::LocalSyntaxPtr; 12use ra_db::LocalSyntaxPtr;
13use ra_syntax::{ 13use ra_syntax::{
14 TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreePtr, 14 TextRange, TextUnit, SourceFile, AstNode, SyntaxNode, TreeArc,
15 ast::{self, NameOwner}, 15 ast::{self, NameOwner},
16}; 16};
17 17
@@ -152,11 +152,11 @@ pub struct MacroExpansion {
152impl MacroExpansion { 152impl MacroExpansion {
153 // FIXME: does not really make sense, macro expansion is not neccessary a 153 // FIXME: does not really make sense, macro expansion is not neccessary a
154 // whole file. See `MacroExpansion::ptr` as well. 154 // whole file. See `MacroExpansion::ptr` as well.
155 pub(crate) fn file(&self) -> TreePtr<SourceFile> { 155 pub(crate) fn file(&self) -> TreeArc<SourceFile> {
156 SourceFile::parse(&self.text) 156 SourceFile::parse(&self.text)
157 } 157 }
158 158
159 pub fn syntax(&self) -> TreePtr<SyntaxNode> { 159 pub fn syntax(&self) -> TreeArc<SyntaxNode> {
160 self.ptr.resolve(&self.file()) 160 self.ptr.resolve(&self.file())
161 } 161 }
162 /// Maps range in the source code to the range in the expanded code. 162 /// Maps range in the source code to the range in the expanded code.
diff --git a/crates/ra_hir/src/module_tree.rs b/crates/ra_hir/src/module_tree.rs
index 50383c6d8..67823e970 100644
--- a/crates/ra_hir/src/module_tree.rs
+++ b/crates/ra_hir/src/module_tree.rs
@@ -5,7 +5,7 @@ use arrayvec::ArrayVec;
5use relative_path::RelativePathBuf; 5use relative_path::RelativePathBuf;
6use ra_db::{FileId, SourceRootId, Cancelable, SourceRoot}; 6use ra_db::{FileId, SourceRootId, Cancelable, SourceRoot};
7use ra_syntax::{ 7use ra_syntax::{
8 SyntaxNode, TreePtr, 8 SyntaxNode, TreeArc,
9 algo::generate, 9 algo::generate,
10 ast::{self, AstNode, NameOwner}, 10 ast::{self, AstNode, NameOwner},
11}; 11};
@@ -170,7 +170,7 @@ impl ModuleId {
170 self, 170 self,
171 tree: &ModuleTree, 171 tree: &ModuleTree,
172 db: &impl HirDatabase, 172 db: &impl HirDatabase,
173 ) -> Vec<(TreePtr<SyntaxNode>, Problem)> { 173 ) -> Vec<(TreeArc<SyntaxNode>, Problem)> {
174 tree.mods[self] 174 tree.mods[self]
175 .children 175 .children
176 .iter() 176 .iter()
@@ -191,7 +191,7 @@ impl LinkId {
191 pub(crate) fn name(self, tree: &ModuleTree) -> &Name { 191 pub(crate) fn name(self, tree: &ModuleTree) -> &Name {
192 &tree.links[self].name 192 &tree.links[self].name
193 } 193 }
194 pub(crate) fn source(self, tree: &ModuleTree, db: &impl HirDatabase) -> TreePtr<ast::Module> { 194 pub(crate) fn source(self, tree: &ModuleTree, db: &impl HirDatabase) -> TreeArc<ast::Module> {
195 let syntax_node = db.file_item(tree.links[self].source); 195 let syntax_node = db.file_item(tree.links[self].source);
196 ast::Module::cast(&syntax_node).unwrap().to_owned() 196 ast::Module::cast(&syntax_node).unwrap().to_owned()
197 } 197 }
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs
index 32be23d8c..214a9d68b 100644
--- a/crates/ra_hir/src/query_definitions.rs
+++ b/crates/ra_hir/src/query_definitions.rs
@@ -5,7 +5,7 @@ use std::{
5 5
6use rustc_hash::FxHashMap; 6use rustc_hash::FxHashMap;
7use ra_syntax::{ 7use ra_syntax::{
8 AstNode, SyntaxNode, TreePtr, 8 AstNode, SyntaxNode, TreeArc,
9 ast::{self, ModuleItemOwner} 9 ast::{self, ModuleItemOwner}
10}; 10};
11use ra_db::{SourceRootId, Cancelable,}; 11use ra_db::{SourceRootId, Cancelable,};
@@ -33,7 +33,7 @@ pub(super) fn file_items(db: &impl HirDatabase, file_id: HirFileId) -> Arc<Sourc
33pub(super) fn file_item( 33pub(super) fn file_item(
34 db: &impl HirDatabase, 34 db: &impl HirDatabase,
35 source_item_id: SourceItemId, 35 source_item_id: SourceItemId,
36) -> TreePtr<SyntaxNode> { 36) -> TreeArc<SyntaxNode> {
37 match source_item_id.item_id { 37 match source_item_id.item_id {
38 Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(), 38 Some(id) => db.file_items(source_item_id.file_id)[id].to_owned(),
39 None => db 39 None => db