Trait Binding

Source
pub trait Binding<'a, Q: QueryContext>:
    Clone
    + Debug
    + PartialEq
    + Sized {
Show 24 methods // Required methods fn from_constant(constant: &'a Constant) -> Self; fn from_node(node: Q::Node<'a>) -> Self; fn from_path(path: &'a Path) -> Self; fn from_range(range: ByteRange, source: &'a str) -> Self; fn singleton(&self) -> Option<Q::Node<'a>>; fn get_sexp(&self) -> Option<String>; fn position(&self, language: &Q::Language<'a>) -> Option<Range>; fn range(&self, language: &Q::Language<'a>) -> Option<ByteRange>; fn code_range(&self, language: &Q::Language<'a>) -> Option<CodeRange>; fn is_equivalent_to(&self, other: &Self, language: &Q::Language<'a>) -> bool; fn is_suppressed( &self, language: &Q::Language<'a>, current_name: Option<&str>, ) -> bool; fn get_insertion_padding( &self, text: &str, is_first: bool, language: &Q::Language<'a>, ) -> Option<String>; fn linearized_text( &self, language: &Q::Language<'a>, effects: &[Effect<'a, Q>], files: &FileRegistry<'a, Q>, memo: &mut HashMap<CodeRange, Option<String>>, distributed_indent: Option<usize>, logs: &mut AnalysisLogs, ) -> GritResult<Cow<'a, str>>; fn text(&self, language: &Q::Language<'a>) -> GritResult<Cow<'_, str>>; fn source(&self) -> Option<&'a str>; fn as_constant(&self) -> Option<&Constant>; fn as_filename(&self) -> Option<&Path>; fn as_node(&self) -> Option<Q::Node<'a>>; fn is_list(&self) -> bool; fn list_items(&self) -> Option<impl Iterator<Item = Q::Node<'a>> + Clone>; fn parent_node(&self) -> Option<Q::Node<'a>>; fn is_truthy(&self) -> bool; fn log_empty_field_rewrite_error( &self, language: &Q::Language<'a>, logs: &mut AnalysisLogs, ) -> GritResult<()>; // Provided method fn from_pattern( pattern: &'a Pattern<Q>, state: &mut State<'a, Q>, context: &'a Q::ExecContext<'a>, logs: &mut AnalysisLogs, ) -> GritResult<Q::Binding<'a>> { ... }
}

Required Methods§

Source

fn from_constant(constant: &'a Constant) -> Self

Source

fn from_node(node: Q::Node<'a>) -> Self

Source

fn from_path(path: &'a Path) -> Self

Source

fn from_range(range: ByteRange, source: &'a str) -> Self

Source

fn singleton(&self) -> Option<Q::Node<'a>>

Source

fn get_sexp(&self) -> Option<String>

Source

fn position(&self, language: &Q::Language<'a>) -> Option<Range>

Source

fn range(&self, language: &Q::Language<'a>) -> Option<ByteRange>

Source

fn code_range(&self, language: &Q::Language<'a>) -> Option<CodeRange>

Source

fn is_equivalent_to(&self, other: &Self, language: &Q::Language<'a>) -> bool

Checks whether two bindings are equivalent.

Bindings are considered equivalent if they refer to the same thing.

Source

fn is_suppressed( &self, language: &Q::Language<'a>, current_name: Option<&str>, ) -> bool

Source

fn get_insertion_padding( &self, text: &str, is_first: bool, language: &Q::Language<'a>, ) -> Option<String>

Returns the padding to use for inserting the given text.

Source

fn linearized_text( &self, language: &Q::Language<'a>, effects: &[Effect<'a, Q>], files: &FileRegistry<'a, Q>, memo: &mut HashMap<CodeRange, Option<String>>, distributed_indent: Option<usize>, logs: &mut AnalysisLogs, ) -> GritResult<Cow<'a, str>>

Source

fn text(&self, language: &Q::Language<'a>) -> GritResult<Cow<'_, str>>

Source

fn source(&self) -> Option<&'a str>

Source

fn as_constant(&self) -> Option<&Constant>

Returns the constant this binding binds to, if and only if it is a constant binding.

Source

fn as_filename(&self) -> Option<&Path>

Returns the path of this binding, if and only if it is a filename binding.

Source

fn as_node(&self) -> Option<Q::Node<'a>>

Returns the node of this binding, if and only if it is a node binding.

Source

fn is_list(&self) -> bool

Returns true if and only if this binding is bound to a list.

Source

fn list_items(&self) -> Option<impl Iterator<Item = Q::Node<'a>> + Clone>

Returns an iterator over the items in a list.

Returns None if the binding is not bound to a list.

Source

fn parent_node(&self) -> Option<Q::Node<'a>>

Returns the parent node of this binding.

Returns None if the binding has no relation to a node.

Source

fn is_truthy(&self) -> bool

Source

fn log_empty_field_rewrite_error( &self, language: &Q::Language<'a>, logs: &mut AnalysisLogs, ) -> GritResult<()>

Provided Methods§

Source

fn from_pattern( pattern: &'a Pattern<Q>, state: &mut State<'a, Q>, context: &'a Q::ExecContext<'a>, logs: &mut AnalysisLogs, ) -> GritResult<Q::Binding<'a>>

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementors§