From d4ef07b2355df891d4f9b7641f0246ebe5bd6a6b Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 21 Dec 2018 15:50:07 +0300 Subject: use completions in API --- crates/ra_analysis/src/completion.rs | 12 +++++------- crates/ra_analysis/src/imp.rs | 3 ++- 2 files changed, 7 insertions(+), 8 deletions(-) (limited to 'crates/ra_analysis/src') diff --git a/crates/ra_analysis/src/completion.rs b/crates/ra_analysis/src/completion.rs index 074033ad8..09894d955 100644 --- a/crates/ra_analysis/src/completion.rs +++ b/crates/ra_analysis/src/completion.rs @@ -24,7 +24,7 @@ pub use crate::completion::completion_item::{CompletionItem, InsertText}; pub(crate) fn completions( db: &db::RootDatabase, position: FilePosition, -) -> Cancelable>> { +) -> Cancelable> { let original_file = db.source_file(position.file_id); // Insert a fake ident to get a valid parse tree let file = { @@ -53,12 +53,10 @@ pub(crate) fn completions( param_completions(&mut acc, name.syntax()); } } - let res = if has_completions { - Some(acc.into()) - } else { - None - }; - Ok(res) + if !has_completions { + return Ok(None); + } + Ok(Some(acc)) } /// Complete repeated parametes, both name and type. For example, if all diff --git a/crates/ra_analysis/src/imp.rs b/crates/ra_analysis/src/imp.rs index 5701e1ae2..340f7c78c 100644 --- a/crates/ra_analysis/src/imp.rs +++ b/crates/ra_analysis/src/imp.rs @@ -219,7 +219,8 @@ impl AnalysisImpl { self.db.crate_graph().crate_root(crate_id) } pub fn completions(&self, position: FilePosition) -> Cancelable>> { - completions(&self.db, position) + let completions = completions(&self.db, position)?; + Ok(completions.map(|it| it.into())) } pub fn approximately_resolve_symbol( &self, -- cgit v1.2.3