pub struct StageOperation {
pub file_path: String,
pub language: Option<LanguageName>,
pub selector: Selector,
pub content: Option<String>,
}
Expand description
Stage an operation and see a preview of the changes
The Selector uses a simple but powerful approach: find text with anchor
(and optionally end
),
then perform the specified operation
. All operations are AST-aware and respect language syntax.
§Basic Usage
Most operations only need an anchor
- a short, unique piece of text to locate:
{“operation”: “insert_after_node”, “anchor”: “fn main() {” }
Replace_range operations also use end
to specify the extent:
{ “operation”: “replace_range”, “anchor”: “// Start here”, “end”: “// End here” }
To delete a syntax node, use one of the replace
operations and omit content
Fields§
§file_path: String
Path to the source file. If a session has been configured, this can be a relative path to the session root.
language: Option<LanguageName>
Optional language hint. If not provided, language will be detected from file extension.
selector: Selector
How to position the content
content: Option<String>
The new content to insert or replace
IMPORTANT TIP: To remove code, use replace
and omit content
Trait Implementations§
Source§impl Debug for StageOperation
impl Debug for StageOperation
Source§impl<'de> Deserialize<'de> for StageOperation
impl<'de> Deserialize<'de> for StageOperation
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl JsonSchema for StageOperation
impl JsonSchema for StageOperation
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
$ref
keyword. Read moreSource§impl Serialize for StageOperation
impl Serialize for StageOperation
Source§impl Tool<SemanticEditTools> for StageOperation
impl Tool<SemanticEditTools> for StageOperation
Source§impl WithExamples for StageOperation
impl WithExamples for StageOperation
Auto Trait Implementations§
impl Freeze for StageOperation
impl RefUnwindSafe for StageOperation
impl Send for StageOperation
impl Sync for StageOperation
impl Unpin for StageOperation
impl UnwindSafe for StageOperation
Blanket Implementations§
Source§impl<T> AsToolSchema for Twhere
T: JsonSchema + WithExamples,
impl<T> AsToolSchema for Twhere
T: JsonSchema + WithExamples,
fn schema() -> ToolSchema
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 more