use completions in API

This commit is contained in:
Aleksey Kladov 2018-12-21 15:50:07 +03:00
parent ba0072401c
commit d4ef07b235
2 changed files with 7 additions and 8 deletions

View File

@ -24,7 +24,7 @@
pub(crate) fn completions(
db: &db::RootDatabase,
position: FilePosition,
) -> Cancelable<Option<Vec<CompletionItem>>> {
) -> Cancelable<Option<Completions>> {
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

View File

@ -219,7 +219,8 @@ pub fn crate_root(&self, crate_id: CrateId) -> FileId {
self.db.crate_graph().crate_root(crate_id)
}
pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> {
completions(&self.db, position)
let completions = completions(&self.db, position)?;
Ok(completions.map(|it| it.into()))
}
pub fn approximately_resolve_symbol(
&self,