diff options
Diffstat (limited to 'crates/libeditor/src/scope')
-rw-r--r-- | crates/libeditor/src/scope/mod_scope.rs | 11 |
1 files changed, 6 insertions, 5 deletions
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 @@ | |||
1 | use libsyntax2::{ | 1 | use libsyntax2::{ |
2 | AstNode, SyntaxNode, SyntaxNodeRef, SmolStr, ast | 2 | AstNode, SyntaxNode, SyntaxNodeRef, SmolStr, |
3 | ast::{self, AstChildren}, | ||
3 | }; | 4 | }; |
4 | 5 | ||
5 | pub struct ModuleScope { | 6 | pub struct ModuleScope { |
@@ -16,9 +17,9 @@ enum EntryKind { | |||
16 | } | 17 | } |
17 | 18 | ||
18 | impl ModuleScope { | 19 | impl ModuleScope { |
19 | pub fn new(m: ast::Root) -> ModuleScope { | 20 | pub fn new(items: AstChildren<ast::ModuleItem>) -> ModuleScope { |
20 | let mut entries = Vec::new(); | 21 | let mut entries = Vec::new(); |
21 | for item in m.items() { | 22 | for item in items { |
22 | let entry = match item { | 23 | let entry = match item { |
23 | ast::ModuleItem::StructDef(item) => Entry::new(item), | 24 | ast::ModuleItem::StructDef(item) => Entry::new(item), |
24 | ast::ModuleItem::EnumDef(item) => Entry::new(item), | 25 | ast::ModuleItem::EnumDef(item) => Entry::new(item), |
@@ -85,11 +86,11 @@ fn collect_imports(tree: ast::UseTree, acc: &mut Vec<Entry>) { | |||
85 | #[cfg(test)] | 86 | #[cfg(test)] |
86 | mod tests { | 87 | mod tests { |
87 | use super::*; | 88 | use super::*; |
88 | use libsyntax2::File; | 89 | use libsyntax2::{File, ast::ModuleItemOwner}; |
89 | 90 | ||
90 | fn do_check(code: &str, expected: &[&str]) { | 91 | fn do_check(code: &str, expected: &[&str]) { |
91 | let file = File::parse(&code); | 92 | let file = File::parse(&code); |
92 | let scope = ModuleScope::new(file.ast()); | 93 | let scope = ModuleScope::new(file.ast().items()); |
93 | let actual = scope.entries | 94 | let actual = scope.entries |
94 | .iter() | 95 | .iter() |
95 | .map(|it| it.name()) | 96 | .map(|it| it.name()) |