From 127814d9a7f62c834c0893ff05e933aac4be89e9 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sat, 8 Sep 2018 01:35:20 +0300 Subject: nested mod completion --- crates/libeditor/src/scope/mod_scope.rs | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'crates/libeditor/src/scope') diff --git a/crates/libeditor/src/scope/mod_scope.rs b/crates/libeditor/src/scope/mod_scope.rs index 67baa8678..0ec56a206 100644 --- a/crates/libeditor/src/scope/mod_scope.rs +++ b/crates/libeditor/src/scope/mod_scope.rs @@ -1,5 +1,6 @@ use libsyntax2::{ - AstNode, SyntaxNode, SyntaxNodeRef, SmolStr, ast + AstNode, SyntaxNode, SyntaxNodeRef, SmolStr, + ast::{self, AstChildren}, }; pub struct ModuleScope { @@ -16,9 +17,9 @@ enum EntryKind { } impl ModuleScope { - pub fn new(m: ast::Root) -> ModuleScope { + pub fn new(items: AstChildren) -> ModuleScope { let mut entries = Vec::new(); - for item in m.items() { + for item in items { let entry = match item { ast::ModuleItem::StructDef(item) => Entry::new(item), ast::ModuleItem::EnumDef(item) => Entry::new(item), @@ -85,11 +86,11 @@ fn collect_imports(tree: ast::UseTree, acc: &mut Vec) { #[cfg(test)] mod tests { use super::*; - use libsyntax2::File; + use libsyntax2::{File, ast::ModuleItemOwner}; fn do_check(code: &str, expected: &[&str]) { let file = File::parse(&code); - let scope = ModuleScope::new(file.ast()); + let scope = ModuleScope::new(file.ast().items()); let actual = scope.entries .iter() .map(|it| it.name()) -- cgit v1.2.3