Struct CompletionItem
#[non_exhaustive]pub struct CompletionItem {Show 13 fields
pub label: CompletionItemLabel,
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<(CompletionItemRefMode, TextSize)>,
pub import_to_add: SmallVec<[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: CompletionItemLabelLabel in the completion pop up which identifies completion.
source_range: TextRangeRange 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: TextEditWhat happens when user selects this item.
Typically, replaces source_range with new identifier.
is_snippet: bool§kind: CompletionItemKindWhat item (struct, function, etc) are we completing.
lookup: SmolStrLookup 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: boolWhether this item is marked as deprecated
trigger_call_info: boolIf completing a function call, ask the editor to show parameter popup after completion.
relevance: CompletionRelevanceWe 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<(CompletionItemRefMode, TextSize)>Indicates that a reference or mutable reference to this variable is a possible match.
import_to_add: SmallVec<[String; 1]>The import data to add to completion’s edits.
Implementations§
§impl CompletionItem
impl CompletionItem
Trait Implementations§
§impl Clone for CompletionItem
impl Clone for CompletionItem
§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 more§impl Debug for CompletionItem
impl Debug for CompletionItem
§impl UpmapFromRaFixture for CompletionItem
impl UpmapFromRaFixture for CompletionItem
fn upmap_from_ra_fixture( self, __analysis: &RaFixtureAnalysis, __virtual_file_id: FileId, __real_file_id: FileId, ) -> Result<CompletionItem, ()>
Auto 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
§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