Skip to main content

TextObjectContext

Struct TextObjectContext 

Source
pub struct TextObjectContext<'a> {
    pub buffer: &'a Buffer,
    pub at: Position,
    pub count: Count,
    pub args: Args,
    pub cancel: &'a CancellationToken,
    pub scope_resolver: Option<&'a dyn ScopeResolver>,
    pub comment_syntax: Option<&'a CommentSyntax>,
    pub path: Option<&'a Path>,
    pub syntax: Option<&'a Arc<dyn Any + Send + Sync>>,
}
Expand description

Context passed to a text-object’s evaluator.

Fields§

§buffer: &'a Buffer

The buffer text the object reads.

§at: Position

The cursor the object is evaluated around.

§count: Count

The count, 1 when none was typed (2aw, 2i().

§args: Args

The object’s own arguments.

§cancel: &'a CancellationToken

Cooperative cancellation handle (DESIGN.md §5.2.5). Most text objects are O(line); polling rarely matters. Tag / paragraph / sentence objects that walk further can poll cancel.check()? on their inner loops.

§scope_resolver: Option<&'a dyn ScopeResolver>

N.1.4a: tree-sitter scope resolver for the structural text objects (af / ac / …), injected by the host (backed by the buffer’s SyntaxSnapshot). None for buffers with no syntax — the structural objects then resolve nothing; the classic objects (iw, ap, i{) never read it.

§comment_syntax: Option<&'a CommentSyntax>

N.1.6: comment-leader descriptor for the comment objects (aC / iC), injected by the host from the active buffer’s language. None (or line: None) ⇒ the comment objects resolve nothing. Only aC / iC read it.

§path: Option<&'a Path>

OM.6b: the file the object’s buffer is backed by — the borrowed peer of MotionContext::path, for the same reason.

§syntax: Option<&'a Arc<dyn Any + Send + Sync>>

OT.1: the type-erased tree-sitter snapshot — the borrowed peer of MotionContext::syntax, for the same reason, and carrying the same version-agreement guarantee.

Distinct from scope_resolver above rather than replacing it: the resolver answers “what scope encloses this point” for the native structural objects, while this hands a plugin the whole tree to query. A plugin object resolving a subtree needs the second, not the first.

Auto Trait Implementations§

§

impl<'a> !RefUnwindSafe for TextObjectContext<'a>

§

impl<'a> !Send for TextObjectContext<'a>

§

impl<'a> !Sync for TextObjectContext<'a>

§

impl<'a> !UnwindSafe for TextObjectContext<'a>

§

impl<'a> Freeze for TextObjectContext<'a>

§

impl<'a> Unpin for TextObjectContext<'a>

§

impl<'a> UnsafeUnpin for TextObjectContext<'a>

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

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