aboutsummaryrefslogtreecommitdiff
path: root/crates
diff options
context:
space:
mode:
Diffstat (limited to 'crates')
-rw-r--r--crates/ra_analysis/src/hir/function/mod.rs10
-rw-r--r--crates/ra_analysis/src/hir/query_definitions.rs4
-rw-r--r--crates/ra_analysis/src/loc2id.rs9
-rw-r--r--crates/ra_analysis/src/syntax_ptr.rs7
4 files changed, 12 insertions, 18 deletions
diff --git a/crates/ra_analysis/src/hir/function/mod.rs b/crates/ra_analysis/src/hir/function/mod.rs
index 9ca8f4e7c..280218fd4 100644
--- a/crates/ra_analysis/src/hir/function/mod.rs
+++ b/crates/ra_analysis/src/hir/function/mod.rs
@@ -11,8 +11,8 @@ use ra_syntax::{
11}; 11};
12 12
13use crate::{ 13use crate::{
14 hir::HirDatabase, 14 hir::{HirDatabase, SourceItemId},
15 syntax_ptr::SyntaxPtr, FileId, 15 FileId,
16}; 16};
17 17
18pub(crate) use self::scope::FnScopes; 18pub(crate) use self::scope::FnScopes;
@@ -20,8 +20,10 @@ pub(crate) use crate::loc2id::FnId;
20 20
21impl FnId { 21impl FnId {
22 pub(crate) fn get(db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef) -> FnId { 22 pub(crate) fn get(db: &impl HirDatabase, file_id: FileId, fn_def: ast::FnDef) -> FnId {
23 let ptr = SyntaxPtr::new(file_id, fn_def.syntax()); 23 let file_items = db.file_items(file_id);
24 db.id_maps().fn_id(ptr) 24 let item_id = file_items.id_of(fn_def.syntax());
25 let item_id = SourceItemId { file_id, item_id };
26 db.id_maps().fn_id(item_id)
25 } 27 }
26} 28}
27 29
diff --git a/crates/ra_analysis/src/hir/query_definitions.rs b/crates/ra_analysis/src/hir/query_definitions.rs
index cdd986ce4..6c633e9ab 100644
--- a/crates/ra_analysis/src/hir/query_definitions.rs
+++ b/crates/ra_analysis/src/hir/query_definitions.rs
@@ -26,8 +26,8 @@ use crate::{
26 26
27/// Resolve `FnId` to the corresponding `SyntaxNode` 27/// Resolve `FnId` to the corresponding `SyntaxNode`
28pub(super) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode { 28pub(super) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode {
29 let ptr = db.id_maps().fn_ptr(fn_id); 29 let item_id = db.id_maps().fn_item_id(fn_id);
30 let syntax = db.resolve_syntax_ptr(ptr); 30 let syntax = db.file_item(item_id);
31 FnDef::cast(syntax.borrowed()).unwrap().owned() 31 FnDef::cast(syntax.borrowed()).unwrap().owned()
32} 32}
33 33
diff --git a/crates/ra_analysis/src/loc2id.rs b/crates/ra_analysis/src/loc2id.rs
index 5b2c0f615..204708942 100644
--- a/crates/ra_analysis/src/loc2id.rs
+++ b/crates/ra_analysis/src/loc2id.rs
@@ -9,7 +9,6 @@ use rustc_hash::FxHashMap;
9 9
10use crate::{ 10use crate::{
11 hir::{SourceItemId, ModuleId}, 11 hir::{SourceItemId, ModuleId},
12 syntax_ptr::SyntaxPtr,
13 input::SourceRootId, 12 input::SourceRootId,
14}; 13};
15 14
@@ -112,10 +111,10 @@ pub(crate) struct IdMaps {
112} 111}
113 112
114impl IdMaps { 113impl IdMaps {
115 pub(crate) fn fn_id(&self, ptr: SyntaxPtr) -> FnId { 114 pub(crate) fn fn_id(&self, item_id: SourceItemId) -> FnId {
116 self.inner.fns.lock().loc2id(&ptr) 115 self.inner.fns.lock().loc2id(&item_id)
117 } 116 }
118 pub(crate) fn fn_ptr(&self, fn_id: FnId) -> SyntaxPtr { 117 pub(crate) fn fn_item_id(&self, fn_id: FnId) -> SourceItemId {
119 self.inner.fns.lock().id2loc(fn_id) 118 self.inner.fns.lock().id2loc(fn_id)
120 } 119 }
121 120
@@ -129,6 +128,6 @@ impl IdMaps {
129 128
130#[derive(Debug, Default)] 129#[derive(Debug, Default)]
131struct IdMapsInner { 130struct IdMapsInner {
132 fns: Mutex<Loc2IdMap<SyntaxPtr, FnId>>, 131 fns: Mutex<Loc2IdMap<SourceItemId, FnId>>,
133 defs: Mutex<Loc2IdMap<DefLoc, DefId>>, 132 defs: Mutex<Loc2IdMap<DefLoc, DefId>>,
134} 133}
diff --git a/crates/ra_analysis/src/syntax_ptr.rs b/crates/ra_analysis/src/syntax_ptr.rs
index ca8efc9b2..7bbf1fc33 100644
--- a/crates/ra_analysis/src/syntax_ptr.rs
+++ b/crates/ra_analysis/src/syntax_ptr.rs
@@ -17,13 +17,6 @@ pub(crate) struct SyntaxPtr {
17 local: LocalSyntaxPtr, 17 local: LocalSyntaxPtr,
18} 18}
19 19
20impl SyntaxPtr {
21 pub(crate) fn new(file_id: FileId, node: SyntaxNodeRef) -> SyntaxPtr {
22 let local = LocalSyntaxPtr::new(node);
23 SyntaxPtr { file_id, local }
24 }
25}
26
27/// A pionter to a syntax node inside a file. 20/// A pionter to a syntax node inside a file.
28#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] 21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
29pub(crate) struct LocalSyntaxPtr { 22pub(crate) struct LocalSyntaxPtr {