pub(in super::super) fn is_if_open(line: &str) -> bool {
let trimmed = line.trim();
trimmed.starts_with("if ") && trimmed.ends_with(" {")
}
pub(in super::super) fn is_else_open(line: &str) -> bool {
let trimmed = line.trim();
trimmed == "else {" || trimmed == "} else {"
}
pub(in super::super) fn is_else_if_open(line: &str) -> bool {
let trimmed = line.trim();
let trimmed = trimmed.strip_prefix("} ").unwrap_or(trimmed);
trimmed.starts_with("else if ") && trimmed.ends_with(" {")
}
pub(in super::super) fn extract_if_condition(line: &str) -> Option<&str> {
let trimmed = line.trim();
let without_prefix = trimmed.strip_prefix("if ")?;
without_prefix.strip_suffix(" {")
}
pub(in super::super) fn extract_else_if_condition(line: &str) -> Option<&str> {
let trimmed = line.trim();
let trimmed = trimmed.strip_prefix("} ").unwrap_or(trimmed);
trimmed.strip_prefix("else if ")?.strip_suffix(" {")
}
pub(in super::super) fn extract_any_if_condition(line: &str) -> Option<&str> {
let trimmed = line.trim();
let trimmed = trimmed.strip_prefix("} ").unwrap_or(trimmed);
let without_prefix = trimmed
.strip_prefix("if ")
.or_else(|| trimmed.strip_prefix("else if "))?;
without_prefix.strip_suffix(" {")
}