Enum cairo_lang_semantic::patcher::RewriteNode
source · pub enum RewriteNode {
Trimmed {
node: SyntaxNode,
trim_left: bool,
trim_right: bool,
},
Copied(SyntaxNode),
Modified(ModifiedNode),
Text(String),
}
Expand description
Interface for modifying syntax nodes.
Variants§
Trimmed
A rewrite node that represents a trimmed copy of a syntax node: one with the leading and trailing trivia excluded.
Copied(SyntaxNode)
Modified(ModifiedNode)
Text(String)
Implementations§
source§impl RewriteNode
impl RewriteNode
pub fn new_trimmed(syntax_node: SyntaxNode) -> Self
pub fn new_modified(children: Vec<RewriteNode>) -> Self
sourcepub fn from_ast<T: TypedSyntaxNode>(node: &T) -> Self
pub fn from_ast<T: TypedSyntaxNode>(node: &T) -> Self
Creates a rewrite node from an AST object.
sourcepub fn modify(&mut self, db: &dyn SyntaxGroup) -> &mut ModifiedNode
pub fn modify(&mut self, db: &dyn SyntaxGroup) -> &mut ModifiedNode
Prepares a node for modification.
sourcepub fn modify_child(
&mut self,
db: &dyn SyntaxGroup,
index: usize
) -> &mut RewriteNode
pub fn modify_child( &mut self, db: &dyn SyntaxGroup, index: usize ) -> &mut RewriteNode
Prepares a node for modification and returns a specific child.
sourcepub fn interpolate_patched(
code: &str,
patches: UnorderedHashMap<String, RewriteNode>
) -> RewriteNode
pub fn interpolate_patched( code: &str, patches: UnorderedHashMap<String, RewriteNode> ) -> RewriteNode
Creates a new Rewrite node by interpolating a string with patches.
Each substring of the form $<name>$
is replaced with syntax nodes from patches
.
A $$
substring is replaced with $
.
Trait Implementations§
source§impl Clone for RewriteNode
impl Clone for RewriteNode
source§fn clone(&self) -> RewriteNode
fn clone(&self) -> RewriteNode
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl Debug for RewriteNode
impl Debug for RewriteNode
source§impl From<SyntaxNode> for RewriteNode
impl From<SyntaxNode> for RewriteNode
source§fn from(node: SyntaxNode) -> Self
fn from(node: SyntaxNode) -> Self
Converts to this type from the input type.
source§impl PartialEq for RewriteNode
impl PartialEq for RewriteNode
source§fn eq(&self, other: &RewriteNode) -> bool
fn eq(&self, other: &RewriteNode) -> bool
This method tests for
self
and other
values to be equal, and is used
by ==
.impl Eq for RewriteNode
impl StructuralEq for RewriteNode
impl StructuralPartialEq for RewriteNode
Auto Trait Implementations§
impl RefUnwindSafe for RewriteNode
impl Send for RewriteNode
impl Sync for RewriteNode
impl Unpin for RewriteNode
impl UnwindSafe for RewriteNode
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
Mutably borrows from an owned value. Read more
source§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Qwhere
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Qwhere Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key
and return true
if they are equal.