pub struct Editor {}Expand description
Editor for structural code modifications
Implementations§
Source§impl Editor
impl Editor
pub fn new() -> Self
Sourcepub fn find_symbol(
&self,
path: &Path,
content: &str,
name: &str,
case_insensitive: bool,
) -> Option<SymbolLocation>
pub fn find_symbol( &self, path: &Path, content: &str, name: &str, case_insensitive: bool, ) -> Option<SymbolLocation>
Find a symbol by name in a file (uses skeleton extractor)
Sourcepub fn delete_symbol(&self, content: &str, loc: &SymbolLocation) -> String
pub fn delete_symbol(&self, content: &str, loc: &SymbolLocation) -> String
Delete a symbol from the content
Sourcepub fn replace_symbol(
&self,
content: &str,
loc: &SymbolLocation,
new_content: &str,
) -> String
pub fn replace_symbol( &self, content: &str, loc: &SymbolLocation, new_content: &str, ) -> String
Replace a symbol with new content
Sourcepub fn insert_before(
&self,
content: &str,
loc: &SymbolLocation,
new_content: &str,
) -> String
pub fn insert_before( &self, content: &str, loc: &SymbolLocation, new_content: &str, ) -> String
Insert content before a symbol
Sourcepub fn insert_after(
&self,
content: &str,
loc: &SymbolLocation,
new_content: &str,
) -> String
pub fn insert_after( &self, content: &str, loc: &SymbolLocation, new_content: &str, ) -> String
Insert content after a symbol
Sourcepub fn prepend_to_file(&self, content: &str, new_content: &str) -> String
pub fn prepend_to_file(&self, content: &str, new_content: &str) -> String
Insert content at the beginning of a file
Sourcepub fn append_to_file(&self, content: &str, new_content: &str) -> String
pub fn append_to_file(&self, content: &str, new_content: &str) -> String
Insert content at the end of a file
Sourcepub fn find_container_body(
&self,
path: &Path,
content: &str,
name: &str,
) -> Option<ContainerBody>
pub fn find_container_body( &self, path: &Path, content: &str, name: &str, ) -> Option<ContainerBody>
Find the body of a container symbol (class, impl block, markdown section) for prepend/append
Sourcepub fn prepend_to_container(
&self,
content: &str,
body: &ContainerBody,
new_content: &str,
) -> String
pub fn prepend_to_container( &self, content: &str, body: &ContainerBody, new_content: &str, ) -> String
Prepend content inside a container (class/impl body)
Sourcepub fn append_to_container(
&self,
content: &str,
body: &ContainerBody,
new_content: &str,
) -> String
pub fn append_to_container( &self, content: &str, body: &ContainerBody, new_content: &str, ) -> String
Append content inside a container (class/impl body)
Sourcepub fn rename_identifier_in_line(
&self,
content: &str,
line_no: usize,
old_name: &str,
new_name: &str,
) -> Option<String>
pub fn rename_identifier_in_line( &self, content: &str, line_no: usize, old_name: &str, new_name: &str, ) -> Option<String>
Rename all word-boundary occurrences of old_name on a specific line (1-based).
Replaces every whole-word occurrence of old_name on that line with new_name.
Returns None if the line number is out of range or if old_name does not
appear as a whole word anywhere on that line.
Sourcepub fn apply_indent(&self, content: &str, indent: &str) -> String
pub fn apply_indent(&self, content: &str, indent: &str) -> String
Apply indentation to content
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Editor
impl RefUnwindSafe for Editor
impl Send for Editor
impl Sync for Editor
impl Unpin for Editor
impl UnsafeUnpin for Editor
impl UnwindSafe for Editor
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
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> 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>
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>
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 moreSource§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
Source§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request