From c303e6fbdfd8d04b645796489766e912d2cb3009 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Sun, 6 Jan 2019 16:05:59 +0300 Subject: fix ra_analysis to work with the new API --- crates/ra_analysis/src/completion/complete_scope.rs | 5 ++++- crates/ra_analysis/src/goto_defenition.rs | 4 ++-- crates/ra_analysis/src/imp.rs | 5 ++--- crates/ra_analysis/src/runnables.rs | 5 ++++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/crates/ra_analysis/src/completion/complete_scope.rs b/crates/ra_analysis/src/completion/complete_scope.rs index 21d77aa97..ee9052d3d 100644 --- a/crates/ra_analysis/src/completion/complete_scope.rs +++ b/crates/ra_analysis/src/completion/complete_scope.rs @@ -20,14 +20,17 @@ pub(super) fn complete_scope(acc: &mut Completions, ctx: &CompletionContext) -> } let module_scope = module.scope(ctx.db)?; + let (file_id, _) = module.defenition_source(ctx.db)?; module_scope .entries() .filter(|(_name, res)| { // Don't expose this item + // FIXME: this penetrates through all kinds of abstractions, + // we need to figura out the way to do it less ugly. match res.import { None => true, Some(import) => { - let range = import.range(ctx.db, module.file_id()); + let range = import.range(ctx.db, file_id); !range.is_subrange(&ctx.leaf.range()) } } diff --git a/crates/ra_analysis/src/goto_defenition.rs b/crates/ra_analysis/src/goto_defenition.rs index 68b6ac3ba..aa0616e3b 100644 --- a/crates/ra_analysis/src/goto_defenition.rs +++ b/crates/ra_analysis/src/goto_defenition.rs @@ -60,8 +60,8 @@ fn name_defenition( if let Some(child_module) = hir::source_binder::module_from_declaration(db, file_id, module)? { - let file_id = child_module.file_id(); - let name = match child_module.name() { + let (file_id, _) = child_module.defenition_source(db)?; + let name = match child_module.name(db)? { Some(name) => name.to_string().into(), None => "".into(), }; diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 44e7aca44..07a966290 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -109,8 +109,7 @@ impl db::RootDatabase { None => return Ok(Vec::new()), Some(it) => it, }; - let (file_id, ast_module) = module.source(self); - let ast_module = match ast_module { + let (file_id, ast_module) = match module.declaration_source(self)? { None => return Ok(Vec::new()), Some(it) => it, }; @@ -206,7 +205,7 @@ impl db::RootDatabase { }) .collect::>(); if let Some(m) = source_binder::module_from_file_id(self, file_id)? { - for (name_node, problem) in m.problems(self) { + for (name_node, problem) in m.problems(self)? { let source_root = self.file_source_root(file_id); let diag = match problem { Problem::UnresolvedModule { candidate } => { diff --git a/crates/ra_analysis/src/runnables.rs b/crates/ra_analysis/src/runnables.rs index f24aa514a..216209098 100644 --- a/crates/ra_analysis/src/runnables.rs +++ b/crates/ra_analysis/src/runnables.rs @@ -72,12 +72,15 @@ fn runnable_mod(db: &RootDatabase, file_id: FileId, module: ast::Module) -> Opti let range = module.syntax().range(); let module = hir::source_binder::module_from_child_node(db, file_id, module.syntax()).ok()??; + + // FIXME: thread cancellation instead of `.ok`ing let path = module .path_to_root(db) .ok()? .into_iter() .rev() - .filter_map(|it| it.name(db).map(Clone::clone)) + .filter_map(|it| it.name(db).ok()) + .filter_map(|it| it) .join("::"); Some(Runnable { range, -- cgit v1.2.3