mod inline;
mod properties;
pub use inline::{InlineVersionUpdate, update_inline_versions};
pub use properties::update_properties;
use crate::error::DepupError;
pub(crate) struct Replacement {
pub start: usize,
pub end: usize,
pub new_value: String,
}
pub(crate) fn apply_replacements(xml: &str, mut replacements: Vec<Replacement>) -> String {
if replacements.is_empty() {
return xml.to_string();
}
replacements.sort_by_key(|r| r.start);
let mut result = String::with_capacity(xml.len());
let mut last_pos = 0;
for r in &replacements {
result.push_str(&xml[last_pos..r.start]);
result.push_str(&r.new_value);
last_pos = r.end;
}
result.push_str(&xml[last_pos..]);
result
}
pub(crate) fn local_name(name: quick_xml::name::QName) -> String {
String::from_utf8_lossy(name.local_name().as_ref()).to_string()
}
pub(crate) fn parse_error(message: &str) -> anyhow::Error {
DepupError::pom_parse_failed("POM XML", message).into()
}