2020-10-25 07:59:15 +00:00
|
|
|
pub(crate) mod attribute;
|
|
|
|
pub(crate) mod dot;
|
|
|
|
pub(crate) mod record;
|
|
|
|
pub(crate) mod pattern;
|
|
|
|
pub(crate) mod fn_param;
|
|
|
|
pub(crate) mod keyword;
|
|
|
|
pub(crate) mod snippet;
|
|
|
|
pub(crate) mod qualified_path;
|
|
|
|
pub(crate) mod unqualified_path;
|
|
|
|
pub(crate) mod postfix;
|
|
|
|
pub(crate) mod macro_in_item_position;
|
|
|
|
pub(crate) mod trait_impl;
|
|
|
|
pub(crate) mod mod_;
|
2020-10-25 08:26:38 +00:00
|
|
|
|
|
|
|
use crate::item::{Builder, CompletionItem};
|
|
|
|
|
|
|
|
/// Represents an in-progress set of completions being built.
|
|
|
|
#[derive(Debug, Default)]
|
|
|
|
pub struct Completions {
|
|
|
|
buf: Vec<CompletionItem>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Completions {
|
|
|
|
pub fn add(&mut self, item: CompletionItem) {
|
|
|
|
self.buf.push(item.into())
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn add_all<I>(&mut self, items: I)
|
|
|
|
where
|
|
|
|
I: IntoIterator,
|
|
|
|
I::Item: Into<CompletionItem>,
|
|
|
|
{
|
|
|
|
items.into_iter().for_each(|item| self.add(item.into()))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Into<Vec<CompletionItem>> for Completions {
|
|
|
|
fn into(self) -> Vec<CompletionItem> {
|
|
|
|
self.buf
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Builder {
|
|
|
|
/// Convenience method, which allows to add a freshly created completion into accumulator
|
|
|
|
/// without binding it to the variable.
|
|
|
|
pub(crate) fn add_to(self, acc: &mut Completions) {
|
|
|
|
acc.add(self.build())
|
|
|
|
}
|
|
|
|
}
|