ide

Struct CompletionItem

source
#[non_exhaustive]
pub struct CompletionItem {
Show 14 fields pub label: SmolStr, pub label_detail: Option<SmolStr>, pub source_range: TextRange, pub text_edit: TextEdit, pub is_snippet: bool, pub kind: CompletionItemKind, pub lookup: SmolStr, pub detail: Option<String>, pub documentation: Option<Documentation>, pub deprecated: bool, pub trigger_call_info: bool, pub relevance: CompletionRelevance, pub ref_match: Option<(Mutability, TextSize)>, pub import_to_add: SmallVec<[(String, String); 1]>,
}
Expand description

CompletionItem describes a single completion entity which expands to 1 or more entries in the editor pop-up.

It is basically a POD with various properties. To construct a CompletionItem, use [Builder::new] method and the [Builder] struct.

Fields (Non-exhaustive)§

This struct is marked as non-exhaustive
Non-exhaustive structs could have additional fields added in future. Therefore, non-exhaustive structs cannot be constructed in external crates using the traditional Struct { .. } syntax; cannot be matched against without a wildcard ..; and struct update syntax will not work.
§label: SmolStr

Label in the completion pop up which identifies completion.

§label_detail: Option<SmolStr>

Additional label details in the completion pop up that are displayed and aligned on the right side after the label.

§source_range: TextRange

Range of identifier that is being completed.

It should be used primarily for UI, but we also use this to convert generic TextEdit into LSP’s completion edit (see conv.rs).

source_range must contain the completion offset. text_edit should start with what source_range points to, or VSCode will filter out the completion silently.

§text_edit: TextEdit

What happens when user selects this item.

Typically, replaces source_range with new identifier.

§is_snippet: bool§kind: CompletionItemKind

What item (struct, function, etc) are we completing.

§lookup: SmolStr

Lookup is used to check if completion item indeed can complete current ident.

That is, in foo.bar$0 lookup of abracadabra will be accepted (it contains bar sub sequence), and quux will rejected.

§detail: Option<String>

Additional info to show in the UI pop up.

§documentation: Option<Documentation>§deprecated: bool

Whether this item is marked as deprecated

§trigger_call_info: bool

If completing a function call, ask the editor to show parameter popup after completion.

§relevance: CompletionRelevance

We use this to sort completion. Relevance records facts like “do the types align precisely?”. We can’t sort by relevances directly, they are only partially ordered.

Note that Relevance ignores fuzzy match score. We compute Relevance for all possible items, and then separately build an ordered completion list based on relevance and fuzzy matching with the already typed identifier.

§ref_match: Option<(Mutability, TextSize)>

Indicates that a reference or mutable reference to this variable is a possible match.

§import_to_add: SmallVec<[(String, String); 1]>

The import data to add to completion’s edits. (ImportPath, LastSegment)

Implementations§

source§

impl CompletionItem

source

pub fn lookup(&self) -> &str

What string is used for filtering.

source

pub fn ref_match(&self) -> Option<(String, Indel, CompletionRelevance)>

Trait Implementations§

source§

impl Clone for CompletionItem

source§

fn clone(&self) -> CompletionItem

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl Debug for CompletionItem

source§

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

Formats the value using the given formatter. Read more

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
§

impl<T> Cast for T

§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

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

source§

unsafe fn clone_to_uninit(&self, dst: *mut T)

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

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.

§

impl<T> IntoBox<dyn Any> for T
where T: Any,

§

fn into_box(self) -> Box<dyn Any>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Send> for T
where T: Any + Send,

§

fn into_box(self) -> Box<dyn Any + Send>

Convert self into the appropriate boxed form.
§

impl<T> IntoBox<dyn Any + Sync + Send> for T
where T: Any + Send + Sync,

§

fn into_box(self) -> Box<dyn Any + Sync + Send>

Convert self into the appropriate boxed form.
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
§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

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

Initializes a with the given initializer. Read more
§

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

Dereferences the given pointer. Read more
§

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

Mutably dereferences the given pointer. Read more
§

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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

impl<'a, T> Captures<'a> for T
where T: ?Sized,