Skip to main content

CompletionSet

Struct CompletionSet 

Source
pub struct CompletionSet {
    pub items: Vec<CompletionItem>,
    pub scope: String,
    pub prefix: String,
    pub replace: SourceRange,
    pub truncated: bool,
    pub incomplete: bool,
}
Expand description

What a completion found: the items, in the order they should be shown, and whether the answer is complete.

Default is written out rather than derived because SourceRange has no default of its own: a range of nothing at offset zero is the same “no edit” the type means everywhere else, and giving SourceRange a Default would make an accidental one compile at every other call site too.

Fields§

§items: Vec<CompletionItem>§scope: String

The scope the names were listed from — ns, Widget, ::, or empty for “wherever the cursor is”.

§prefix: String

What of the name is already written before the cursor, which is what filters the list.

§replace: SourceRange

The range a client replaces with the chosen item.

§truncated: bool

Distinct from the analysis being incomplete, and the distinction is the protocol’s isIncomplete: a client told “incomplete” asks again as the user types, which is exactly right while a background index is still reading files and exactly wrong when the answer was merely capped — the retry would return the same capped list for ever.

§incomplete: bool

Was the analysis itself incomplete — a class this answer depends on that could not be read?

The protocol’s isIncomplete means one thing: ask again later. truncated is a budget, and re-asking returns the same list; this is the other kind — a class whose facts the index does not have yet, so the members are missing rather than few. Measured on a real project: std::string* message; message-> offered one item on the first keystroke (operator basic_string_view, the only member the raw reading of <xstring> had at file scope) and 58 once the file was cooked. A list that looks final and holds a quarter of the truth is worse than an empty one, because the reader believes it.

Implementations§

Source§

impl CompletionSet

Source

pub fn nothing_matched(&self) -> bool

Did the answer hold nothing that could be what the reader is typing?

A client filters the list by the typed prefix and, on an empty result, shows “no suggestions” — and some clients cache that for the prefix, so only the next keystroke re-opens the question. An answer holding nothing that matches is therefore not final, whatever the reason: the file’s closure was still being read, its summary had just been dropped by an edit, or the gathering layer stopped short.

The test is the engine’s own matcher rather than a prefix comparison, because gp legitimately matches getPid without being a prefix of it — a list that answered getPid did answer what was typed.

Trait Implementations§

Source§

impl Clone for CompletionSet

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CompletionSet

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CompletionSet

Source§

fn default() -> CompletionSet

Returns the “default value” for a type. Read more
Source§

impl Eq for CompletionSet

Source§

impl PartialEq for CompletionSet

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for CompletionSet

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.