1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
use super::CompletionItem;

/// Represents a collection of [completion items](#CompletionItem) to be presented
/// in the editor.
#[derive(Debug, Serialize)]
pub struct CompletionList {
    /// This list it not complete. Further typing results in recomputing this list.
    pub is_incomplete: bool,

    /// The completion items.
    pub items: Vec<CompletionItem>,
}

/// The CompletionList namespace provides functions to deal with
/// completion lists.
impl CompletionList {
    /// Creates a new completion list.
    ///
    /// @param items The completion items.
    /// @param isIncomplete The list is not complete.
    pub fn create(items: Option<Vec<CompletionItem>>, is_incomplete: Option<bool>) -> Self {
        CompletionList {
            items: match items {
                Some(items) => items,
                None => Vec::new(),
            },
            is_incomplete: match is_incomplete {
                Some(is_incomplete) => is_incomplete,
                None => false,
            },
        }
    }
}