Skip to main content

griz_core/
pattern_locator.rs

1//! The `pattern` locator: an alternative to `find`/`range` that locates a
2//! [`crate::Op::Replace`] by syntax shape instead of by text.
3
4use schemars::JsonSchema;
5use serde::{Deserialize, Serialize};
6
7/// A structural pattern that locates an edit inside one file.
8#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize, JsonSchema)]
9#[serde(deny_unknown_fields)]
10pub struct PatternLocator {
11    /// Structural pattern, e.g. `foo($A, $$$REST)`.
12    pub pattern: String,
13    /// Language to parse with; defaults to the file's extension.
14    #[serde(default, skip_serializing_if = "Option::is_none")]
15    pub language: Option<String>,
16}