use proc_macro2::Span;
#[derive(Debug, Clone)]
pub struct QualifiedPath {
pub original: String,
pub replacement: String,
pub import: String,
pub segments: Vec<String>,
pub span: Span,
}
impl QualifiedPath {
#[inline]
pub fn last_ident(&self) -> &str {
self.segments.last().map_or("", String::as_str)
}
#[inline]
pub fn import_tail(&self) -> &str {
self.import.rsplit("::").next().unwrap_or_default()
}
#[inline]
pub fn core_ident(&self) -> &str {
let total = self.segments.len();
if total >= 2
&& let Some(prev) = self.segments.get(total - 2)
&& prev.as_bytes().first().is_some_and(u8::is_ascii_uppercase)
{
prev.as_str()
} else {
self.last_ident()
}
}
}