diff options
author | Aleksey Kladov <[email protected]> | 2018-11-18 13:21:23 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-11-18 13:21:23 +0000 |
commit | 4e48917c00d24e1e1785e1959a2f3495a902410b (patch) | |
tree | 0ae3a1f3c92ce9e308934e023d6a24385b4260d6 /crates/ra_analysis/src/descriptors/function | |
parent | cb22a799d60c6c5f81ad0f3d0361f575264f3bc2 (diff) |
use loc2id for FnIds
Diffstat (limited to 'crates/ra_analysis/src/descriptors/function')
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/imp.rs | 4 | ||||
-rw-r--r-- | crates/ra_analysis/src/descriptors/function/mod.rs | 13 |
2 files changed, 9 insertions, 8 deletions
diff --git a/crates/ra_analysis/src/descriptors/function/imp.rs b/crates/ra_analysis/src/descriptors/function/imp.rs index a989a04cd..a7257acf9 100644 --- a/crates/ra_analysis/src/descriptors/function/imp.rs +++ b/crates/ra_analysis/src/descriptors/function/imp.rs | |||
@@ -8,9 +8,9 @@ use crate::descriptors::{ | |||
8 | }; | 8 | }; |
9 | 9 | ||
10 | /// Resolve `FnId` to the corresponding `SyntaxNode` | 10 | /// Resolve `FnId` to the corresponding `SyntaxNode` |
11 | /// TODO: this should return something more type-safe then `SyntaxNode` | ||
12 | pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { | 11 | pub(crate) fn fn_syntax(db: &impl DescriptorDatabase, fn_id: FnId) -> FnDefNode { |
13 | let syntax = db.resolve_syntax_ptr(fn_id.0); | 12 | let ptr = db.id_maps().fn_ptr(fn_id); |
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 | ||
diff --git a/crates/ra_analysis/src/descriptors/function/mod.rs b/crates/ra_analysis/src/descriptors/function/mod.rs index d5db28a64..86eee5e93 100644 --- a/crates/ra_analysis/src/descriptors/function/mod.rs +++ b/crates/ra_analysis/src/descriptors/function/mod.rs | |||
@@ -8,17 +8,18 @@ use ra_syntax::{ | |||
8 | TextRange, TextUnit, | 8 | TextRange, TextUnit, |
9 | }; | 9 | }; |
10 | 10 | ||
11 | use crate::{syntax_ptr::SyntaxPtr, FileId}; | 11 | use crate::{ |
12 | syntax_ptr::SyntaxPtr, FileId, | ||
13 | loc2id::IdDatabase, | ||
14 | }; | ||
12 | 15 | ||
13 | pub(crate) use self::scope::{resolve_local_name, FnScopes}; | 16 | pub(crate) use self::scope::{resolve_local_name, FnScopes}; |
14 | 17 | pub(crate) use crate::loc2id::FnId; | |
15 | #[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)] | ||
16 | pub(crate) struct FnId(SyntaxPtr); | ||
17 | 18 | ||
18 | impl FnId { | 19 | impl FnId { |
19 | pub(crate) fn new(file_id: FileId, fn_def: ast::FnDef) -> FnId { | 20 | pub(crate) fn get(db: &impl IdDatabase, file_id: FileId, fn_def: ast::FnDef) -> FnId { |
20 | let ptr = SyntaxPtr::new(file_id, fn_def.syntax()); | 21 | let ptr = SyntaxPtr::new(file_id, fn_def.syntax()); |
21 | FnId(ptr) | 22 | db.id_maps().fn_id(ptr) |
22 | } | 23 | } |
23 | } | 24 | } |
24 | 25 | ||