From 4d87799a4a73e5a58fce4e3caa88ad90347bdabb Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Tue, 27 Nov 2018 14:04:25 +0300 Subject: implement file_items --- crates/ra_analysis/src/descriptors/module/nameres.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) (limited to 'crates/ra_analysis/src/descriptors/module') diff --git a/crates/ra_analysis/src/descriptors/module/nameres.rs b/crates/ra_analysis/src/descriptors/module/nameres.rs index 6251f5b86..6e327e374 100644 --- a/crates/ra_analysis/src/descriptors/module/nameres.rs +++ b/crates/ra_analysis/src/descriptors/module/nameres.rs @@ -24,7 +24,7 @@ use rustc_hash::FxHashMap; use ra_syntax::{ SyntaxNode, SmolStr, SyntaxKind::{self, *}, - ast::{self, ModuleItemOwner} + ast::{self, ModuleItemOwner, AstNode} }; use crate::{ @@ -44,7 +44,13 @@ use crate::{ pub(crate) struct FileItemId(u32); pub(crate) fn file_items(db: &impl DescriptorDatabase, file_id: FileId) -> Arc> { - unimplemented!() + let source_file = db.file_syntax(file_id); + let source_file = source_file.borrowed(); + let res = source_file.syntax().descendants() + .filter_map(ast::ModuleItem::cast) + .map(|it| it.syntax().owned()) + .collect::>(); + Arc::new(res) } pub(crate) fn file_item(db: &impl DescriptorDatabase, file_id: FileId, file_item_id: FileItemId) -> SyntaxNode { -- cgit v1.2.3