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: StringThe scope the names were listed from — ns, Widget, ::, or empty for “wherever the cursor is”.
prefix: StringWhat of the name is already written before the cursor, which is what filters the list.
replace: SourceRangeThe range a client replaces with the chosen item.
truncated: boolDistinct 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: boolWas 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
impl CompletionSet
Sourcepub fn nothing_matched(&self) -> bool
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
impl Clone for CompletionSet
Source§impl Debug for CompletionSet
impl Debug for CompletionSet
Source§impl Default for CompletionSet
impl Default for CompletionSet
Source§fn default() -> CompletionSet
fn default() -> CompletionSet
impl Eq for CompletionSet
Source§impl PartialEq for CompletionSet
impl PartialEq for CompletionSet
impl StructuralPartialEq for CompletionSet
Auto Trait Implementations§
impl Forget for CompletionSet
impl Freeze for CompletionSet
impl RefUnwindSafe for CompletionSet
impl Send for CompletionSet
impl Sync for CompletionSet
impl Unpin for CompletionSet
impl UnsafeUnpin for CompletionSet
impl UnwindSafe for CompletionSet
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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