use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum IdSource {
Explicit,
Generated,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
pub struct ExpectedBlock {
pub raw: String,
pub format: ExpectedFormat,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
pub enum ExpectedFormat {
TreeSitterSexp,
AstJson,
DiagnosticsJson,
PlainText,
Unknown,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Section {
pub id: String,
pub id_source: IdSource,
pub explicit_id: Option<String>,
pub generated_id: Option<String>,
pub title: String,
pub file: String,
pub tags: Vec<String>,
pub perl: Option<String>,
pub flags: Vec<String>,
pub body: String,
pub expected: Option<ExpectedBlock>,
#[serde(skip_serializing_if = "Option::is_none")]
pub line: Option<usize>,
}
impl Section {
pub fn has_tag(&self, tag: &str) -> bool {
self.tags.iter().any(|t| t == tag)
}
pub fn has_flag(&self, flag: &str) -> bool {
self.flags.iter().any(|f| f == flag)
}
}