From f3fb59d7077801a3a68d2d03eef17d59c2925ae8 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Wed, 31 Oct 2018 20:59:17 +0300 Subject: Move completion to ra_analysis While we should handle completion for isolated file, it's better achieved by using empty Analysis, rather than working only with &File: we need memoization for type inference even inside a single file. --- crates/ra_analysis/src/descriptors/module/scope.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'crates/ra_analysis/src/descriptors/module') diff --git a/crates/ra_analysis/src/descriptors/module/scope.rs b/crates/ra_analysis/src/descriptors/module/scope.rs index 0f8f325ab..846b8b44f 100644 --- a/crates/ra_analysis/src/descriptors/module/scope.rs +++ b/crates/ra_analysis/src/descriptors/module/scope.rs @@ -30,8 +30,12 @@ enum EntryKind { impl ModuleScope { pub fn new(file: &File) -> ModuleScope { + ModuleScope::from_items(file.ast().items()) + } + + pub fn from_items<'a>(items: impl Iterator>) -> ModuleScope { let mut entries = Vec::new(); - for item in file.ast().items() { + for item in items { let entry = match item { ast::ModuleItem::StructDef(item) => Entry::new(item), ast::ModuleItem::EnumDef(item) => Entry::new(item), -- cgit v1.2.3