use {
crate::*,
std::path::PathBuf,
};
#[derive(Debug)]
pub struct Line {
pub item_idx: usize,
pub line_type: LineType,
pub content: TLine,
}
impl Line {
pub fn location(&self) -> Option<&str> {
match self.line_type {
LineType::Location => {
info!("CON: {:#?}", &self.content);
self.content.strings.get(2).map(|ts| ts.raw.as_str())
}
_ => None,
}
}
pub fn location_path(&self, mission: &Mission) -> Option<PathBuf> {
let location_path = self.location()?;
let mut location_path = PathBuf::from(location_path);
if !location_path.is_absolute() {
location_path = mission.workspace_root.join(location_path);
}
Some(location_path)
}
}
impl WrappableLine for Line {
fn content(&self) -> &TLine {
&self.content
}
fn prefix_cols(&self) -> usize {
self.line_type.cols()
}
}