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§
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>
Sourcefn is_equivalent_to(&self, other: &Self, language: &Q::Language<'a>) -> bool
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.
fn is_suppressed( &self, language: &Q::Language<'a>, current_name: Option<&str>, ) -> bool
Sourcefn get_insertion_padding(
&self,
text: &str,
is_first: bool,
language: &Q::Language<'a>,
) -> Option<String>
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.
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>
Sourcefn as_constant(&self) -> Option<&Constant>
fn as_constant(&self) -> Option<&Constant>
Returns the constant this binding binds to, if and only if it is a constant binding.
Sourcefn as_filename(&self) -> Option<&Path>
fn as_filename(&self) -> Option<&Path>
Returns the path of this binding, if and only if it is a filename binding.
Sourcefn as_node(&self) -> Option<Q::Node<'a>>
fn as_node(&self) -> Option<Q::Node<'a>>
Returns the node of this binding, if and only if it is a node binding.
Sourcefn list_items(&self) -> Option<impl Iterator<Item = Q::Node<'a>> + Clone>
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.
Sourcefn parent_node(&self) -> Option<Q::Node<'a>>
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.
fn is_truthy(&self) -> bool
fn log_empty_field_rewrite_error( &self, language: &Q::Language<'a>, logs: &mut AnalysisLogs, ) -> GritResult<()>
Provided Methods§
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.