pub use crate::bindings::diffr::plugin::types::{
Annotation, Cut, FileEntry, FileRef, FileSides, FileStatus, Kind, Leaf, Move, Position,
QuerySource, Range, Region, Side, Source, SourceSides, Span, Visibility,
};
use crate::tree::Pairing;
pub const ROOT: u32 = 0;
impl FileEntry {
pub fn sides(&self) -> Pairing<&FileRef> {
match &self.file {
FileSides::Both((lhs, rhs)) => Pairing::Both { lhs, rhs },
FileSides::LeftOnly(lhs) => Pairing::LeftOnly { lhs },
FileSides::RightOnly(rhs) => Pairing::RightOnly { rhs },
}
}
pub fn side(&self) -> &FileRef {
match &self.file {
FileSides::Both((_, rhs)) | FileSides::RightOnly(rhs) => rhs,
FileSides::LeftOnly(lhs) => lhs,
}
}
pub fn path(&self) -> &str {
&self.side().path
}
}
impl Range {
pub fn lines(&self) -> std::ops::Range<u32> {
let end = if self.end.column == 0 {
self.end.line
} else {
self.end.line + 1
};
self.start.line..end
}
}
impl Default for Visibility {
fn default() -> Self {
Self {
collapsed: false,
label: String::new(),
}
}
}