pub struct SyntaxEditor {
root: SyntaxNode,
changes: RefCell<Vec<Change>>,
annotations: RefCell<Vec<(SyntaxElement, SyntaxAnnotation)>>,
make: SyntaxFactory,
}Fields§
§root: SyntaxNode§changes: RefCell<Vec<Change>>§annotations: RefCell<Vec<(SyntaxElement, SyntaxAnnotation)>>§make: SyntaxFactoryImplementations§
Source§impl SyntaxEditor
impl SyntaxEditor
Sourcepub fn add_generic_param(
&self,
node: &impl HasGenericParams,
new_param: GenericParam,
)
pub fn add_generic_param( &self, node: &impl HasGenericParams, new_param: GenericParam, )
Adds a new generic param to the node using SyntaxEditor
Source§impl SyntaxEditor
impl SyntaxEditor
Sourcepub fn new(root: SyntaxNode) -> (Self, SyntaxNode)
pub fn new(root: SyntaxNode) -> (Self, SyntaxNode)
Creates a syntax editor from root.
The returned root is guaranteed to be a detached, immutable node.
If the provided node is not a root (i.e., has a parent), it is cloned
into a fresh subtree to satisfy syntax editor invariants.
Sourcepub fn with_ast_node<T>(root: &T) -> (Self, T)where
T: AstNode,
pub fn with_ast_node<T>(root: &T) -> (Self, T)where
T: AstNode,
Typed-node variant of SyntaxEditor::new.
pub fn make(&self) -> &SyntaxFactory
pub fn add_annotation( &self, element: impl Element, annotation: SyntaxAnnotation, )
pub fn add_annotation_all( &self, elements: Vec<impl Element>, annotation: SyntaxAnnotation, )
pub fn merge(&self, other: SyntaxEditor)
pub fn insert(&self, position: Position, element: impl Element)
pub fn insert_all(&self, position: Position, elements: Vec<SyntaxElement>)
pub fn insert_with_whitespace(&self, position: Position, element: impl Element)
pub fn insert_all_with_whitespace( &self, position: Position, elements: Vec<SyntaxElement>, )
pub fn delete(&self, element: impl Element)
pub fn delete_all(&self, range: RangeInclusive<SyntaxElement>)
pub fn replace(&self, old: impl Element, new: impl Element)
pub fn replace_with_many(&self, old: impl Element, new: Vec<SyntaxElement>)
pub fn replace_all( &self, range: RangeInclusive<SyntaxElement>, new: Vec<SyntaxElement>, )
pub fn finish(self) -> SyntaxEdit
pub fn deleted(&self, element: impl Element) -> bool
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for SyntaxEditor
impl !RefUnwindSafe for SyntaxEditor
impl !Send for SyntaxEditor
impl !Sync for SyntaxEditor
impl !UnwindSafe for SyntaxEditor
impl Unpin for SyntaxEditor
impl UnsafeUnpin for SyntaxEditor
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
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> 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> ⓘ
Converts
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> ⓘ
Converts
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