mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-09-30 22:01:37 +00:00
use completions in API
This commit is contained in:
parent
ba0072401c
commit
d4ef07b235
2 changed files with 7 additions and 8 deletions
|
@ -24,7 +24,7 @@ pub use crate::completion::completion_item::{CompletionItem, InsertText};
|
||||||
pub(crate) fn completions(
|
pub(crate) fn completions(
|
||||||
db: &db::RootDatabase,
|
db: &db::RootDatabase,
|
||||||
position: FilePosition,
|
position: FilePosition,
|
||||||
) -> Cancelable<Option<Vec<CompletionItem>>> {
|
) -> Cancelable<Option<Completions>> {
|
||||||
let original_file = db.source_file(position.file_id);
|
let original_file = db.source_file(position.file_id);
|
||||||
// Insert a fake ident to get a valid parse tree
|
// Insert a fake ident to get a valid parse tree
|
||||||
let file = {
|
let file = {
|
||||||
|
@ -53,12 +53,10 @@ pub(crate) fn completions(
|
||||||
param_completions(&mut acc, name.syntax());
|
param_completions(&mut acc, name.syntax());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let res = if has_completions {
|
if !has_completions {
|
||||||
Some(acc.into())
|
return Ok(None);
|
||||||
} else {
|
}
|
||||||
None
|
Ok(Some(acc))
|
||||||
};
|
|
||||||
Ok(res)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Complete repeated parametes, both name and type. For example, if all
|
/// Complete repeated parametes, both name and type. For example, if all
|
||||||
|
|
|
@ -219,7 +219,8 @@ impl AnalysisImpl {
|
||||||
self.db.crate_graph().crate_root(crate_id)
|
self.db.crate_graph().crate_root(crate_id)
|
||||||
}
|
}
|
||||||
pub fn completions(&self, position: FilePosition) -> Cancelable<Option<Vec<CompletionItem>>> {
|
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(
|
pub fn approximately_resolve_symbol(
|
||||||
&self,
|
&self,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue