diff options
author | Aleksey Kladov <[email protected]> | 2018-12-27 20:51:44 +0000 |
---|---|---|
committer | Aleksey Kladov <[email protected]> | 2018-12-27 20:51:44 +0000 |
commit | dddbac68779d068cabfa511bed4ba105bc43d194 (patch) | |
tree | 151debc868ea523fd02bb7088faea7b6e2d7bfed /crates/ra_hir/src/query_definitions.rs | |
parent | efb63a7666cc9532d97fa7e0da14b540ae8bd5df (diff) |
remove FnId
Diffstat (limited to 'crates/ra_hir/src/query_definitions.rs')
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 23 |
1 files changed, 8 insertions, 15 deletions
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index e6241342a..56e3f7e9d 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -5,15 +5,15 @@ use std::{ | |||
5 | 5 | ||
6 | use rustc_hash::FxHashMap; | 6 | use rustc_hash::FxHashMap; |
7 | use ra_syntax::{ | 7 | use ra_syntax::{ |
8 | AstNode, SyntaxNode, SmolStr, | 8 | AstNode, SyntaxNode, SmolStr, |
9 | ast::{self, FnDef, FnDefNode, NameOwner, ModuleItemOwner} | 9 | ast::{self, NameOwner, ModuleItemOwner} |
10 | }; | 10 | }; |
11 | use ra_db::{SourceRootId, FileId, Cancelable,}; | 11 | use ra_db::{SourceRootId, FileId, Cancelable,}; |
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName, | 14 | SourceFileItems, SourceItemId, DefKind, Function, DefId, Name, AsName, |
15 | db::HirDatabase, | 15 | db::HirDatabase, |
16 | function::{FnScopes, FnId}, | 16 | function::FnScopes, |
17 | module::{ | 17 | module::{ |
18 | ModuleSource, ModuleSourceNode, ModuleId, | 18 | ModuleSource, ModuleSourceNode, ModuleId, |
19 | imp::Submodule, | 19 | imp::Submodule, |
@@ -23,22 +23,15 @@ use crate::{ | |||
23 | adt::{StructData, EnumData}, | 23 | adt::{StructData, EnumData}, |
24 | }; | 24 | }; |
25 | 25 | ||
26 | /// Resolve `FnId` to the corresponding `SyntaxNode` | 26 | pub(super) fn fn_scopes(db: &impl HirDatabase, def_id: DefId) -> Arc<FnScopes> { |
27 | pub(super) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode { | 27 | let function = Function::new(def_id); |
28 | let def_loc = fn_id.0.loc(db); | 28 | let syntax = function.syntax(db); |
29 | assert!(def_loc.kind == DefKind::Function); | ||
30 | let syntax = db.file_item(def_loc.source_item_id); | ||
31 | FnDef::cast(syntax.borrowed()).unwrap().owned() | ||
32 | } | ||
33 | |||
34 | pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> { | ||
35 | let syntax = db.fn_syntax(fn_id); | ||
36 | let res = FnScopes::new(syntax.borrowed()); | 29 | let res = FnScopes::new(syntax.borrowed()); |
37 | Arc::new(res) | 30 | Arc::new(res) |
38 | } | 31 | } |
39 | 32 | ||
40 | pub(super) fn infer(db: &impl HirDatabase, fn_id: FnId) -> Cancelable<Arc<InferenceResult>> { | 33 | pub(super) fn infer(db: &impl HirDatabase, def_id: DefId) -> Cancelable<Arc<InferenceResult>> { |
41 | let function = Function { fn_id }; | 34 | let function = Function::new(def_id); |
42 | ty::infer(db, function).map(Arc::new) | 35 | ty::infer(db, function).map(Arc::new) |
43 | } | 36 | } |
44 | 37 | ||