diff options
Diffstat (limited to 'crates/ra_hir/src/query_definitions.rs')
-rw-r--r-- | crates/ra_hir/src/query_definitions.rs | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/crates/ra_hir/src/query_definitions.rs b/crates/ra_hir/src/query_definitions.rs index 6f602878c..e4d721601 100644 --- a/crates/ra_hir/src/query_definitions.rs +++ b/crates/ra_hir/src/query_definitions.rs | |||
@@ -11,21 +11,21 @@ use ra_syntax::{ | |||
11 | use ra_db::{SourceRootId, FileId, Cancelable,}; | 11 | use ra_db::{SourceRootId, FileId, Cancelable,}; |
12 | 12 | ||
13 | use crate::{ | 13 | use crate::{ |
14 | FnId, | 14 | SourceFileItems, SourceItemId, DefKind, |
15 | SourceFileItems, SourceItemId, | 15 | db::HirDatabase, |
16 | db::HirDatabase, | 16 | function::{FnScopes, FnId}, |
17 | function::FnScopes, | 17 | module::{ |
18 | module::{ | 18 | ModuleSource, ModuleSourceNode, ModuleId, |
19 | ModuleSource, ModuleSourceNode, ModuleId, | 19 | imp::Submodule, |
20 | imp::Submodule, | 20 | nameres::{InputModuleItems, ItemMap, Resolver}, |
21 | nameres::{InputModuleItems, ItemMap, Resolver}, | 21 | }, |
22 | }, | ||
23 | }; | 22 | }; |
24 | 23 | ||
25 | /// Resolve `FnId` to the corresponding `SyntaxNode` | 24 | /// Resolve `FnId` to the corresponding `SyntaxNode` |
26 | pub(super) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode { | 25 | pub(super) fn fn_syntax(db: &impl HirDatabase, fn_id: FnId) -> FnDefNode { |
27 | let item_id = fn_id.loc(db); | 26 | let def_loc = fn_id.0.loc(db); |
28 | let syntax = db.file_item(item_id); | 27 | assert!(def_loc.kind == DefKind::Function); |
28 | let syntax = db.file_item(def_loc.source_item_id); | ||
29 | FnDef::cast(syntax.borrowed()).unwrap().owned() | 29 | FnDef::cast(syntax.borrowed()).unwrap().owned() |
30 | } | 30 | } |
31 | 31 | ||
@@ -36,9 +36,10 @@ pub(super) fn fn_scopes(db: &impl HirDatabase, fn_id: FnId) -> Arc<FnScopes> { | |||
36 | } | 36 | } |
37 | 37 | ||
38 | pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<SourceFileItems> { | 38 | pub(super) fn file_items(db: &impl HirDatabase, file_id: FileId) -> Arc<SourceFileItems> { |
39 | let mut res = SourceFileItems::default(); | ||
39 | let source_file = db.source_file(file_id); | 40 | let source_file = db.source_file(file_id); |
41 | res.alloc(source_file.syntax().owned()); | ||
40 | let source_file = source_file.borrowed(); | 42 | let source_file = source_file.borrowed(); |
41 | let mut res = SourceFileItems::default(); | ||
42 | source_file | 43 | source_file |
43 | .syntax() | 44 | .syntax() |
44 | .descendants() | 45 | .descendants() |