use rowan::TextRange;
use smol_str::SmolStr;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct LabelId(pub(crate) u32);
impl LabelId {
pub(crate) fn from_index(i: usize) -> Self {
Self(i as u32)
}
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub struct RefId(pub(crate) u32);
impl RefId {
pub(crate) fn from_index(i: usize) -> Self {
Self(i as u32)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LabelDef {
pub name: SmolStr,
pub range: TextRange,
pub key_range: TextRange,
pub referenced: bool,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
pub enum RefCommand {
Ref,
PageRef,
EqRef,
AutoRef,
NameRef,
Cref,
CrefUpper,
Vref,
VrefUpper,
CpageRef,
}
impl RefCommand {
pub fn is_key_list(self) -> bool {
matches!(
self,
RefCommand::Cref
| RefCommand::CrefUpper
| RefCommand::Vref
| RefCommand::VrefUpper
| RefCommand::CpageRef
)
}
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct LabelRef {
pub name: SmolStr,
pub command: RefCommand,
pub range: TextRange,
pub key_range: TextRange,
pub resolved: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct CitationRef {
pub name: SmolStr,
pub command: SmolStr,
pub range: TextRange,
pub key_range: TextRange,
}