Struct ide::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
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§
Trait Implementations§
source§impl Clone for CompletionItem
impl Clone for CompletionItem
source§fn clone(&self) -> CompletionItem
fn clone(&self) -> CompletionItem
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moreAuto Trait Implementations§
impl Freeze for CompletionItem
impl RefUnwindSafe for CompletionItem
impl Send for CompletionItem
impl Sync for CompletionItem
impl Unpin for CompletionItem
impl UnwindSafe for CompletionItem
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
§impl<T> Cast for T
impl<T> Cast for T
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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