2023-12-27 15:52:59 +00:00
|
|
|
use std::borrow::Cow;
|
|
|
|
|
2023-12-27 14:31:54 +00:00
|
|
|
use crate::compare::Token;
|
2023-12-27 16:10:40 +00:00
|
|
|
use crate::wasm::WasmAstNode;
|
2023-12-27 14:31:54 +00:00
|
|
|
use crate::wasm::WasmDocument;
|
|
|
|
|
|
|
|
pub fn wasm_compare_document<'b, 's>(
|
2023-12-27 16:10:40 +00:00
|
|
|
source: &'s str,
|
2023-12-27 14:31:54 +00:00
|
|
|
emacs: &'b Token<'s>,
|
2023-12-27 16:10:40 +00:00
|
|
|
wasm: WasmDocument<'s>,
|
2023-12-27 15:52:59 +00:00
|
|
|
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
2023-12-27 16:10:40 +00:00
|
|
|
// wasm_compare_ast_node(
|
2023-12-27 14:31:54 +00:00
|
|
|
todo!()
|
|
|
|
}
|
2023-12-27 15:52:59 +00:00
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub enum WasmDiffEntry<'b, 's> {
|
|
|
|
WasmDiffResult(WasmDiffResult<'b, 's>),
|
|
|
|
WasmDiffLayer(WasmDiffLayer<'b, 's>),
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct WasmDiffResult<'b, 's> {
|
|
|
|
status: WasmDiffStatus,
|
|
|
|
name: Cow<'s, str>,
|
|
|
|
message: Option<String>,
|
|
|
|
children: Vec<WasmDiffEntry<'b, 's>>,
|
|
|
|
rust_source: &'s str,
|
|
|
|
#[allow(dead_code)]
|
|
|
|
emacs_token: &'b Token<'s>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub(crate) enum WasmDiffStatus {
|
|
|
|
Good,
|
|
|
|
Bad,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Debug)]
|
|
|
|
pub struct WasmDiffLayer<'b, 's> {
|
|
|
|
name: Cow<'s, str>,
|
|
|
|
children: Vec<WasmDiffEntry<'b, 's>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
impl<'b, 's> WasmDiffEntry<'b, 's> {
|
|
|
|
// fn has_bad_children(&self) -> bool {
|
|
|
|
// match self {
|
|
|
|
// DiffEntry::DiffResult(diff) => &diff.children,
|
|
|
|
// DiffEntry::DiffLayer(diff) => &diff.children,
|
|
|
|
// }
|
|
|
|
// .iter()
|
|
|
|
// .any(|child| child.is_immediately_bad() || child.has_bad_children())
|
|
|
|
// }
|
|
|
|
|
|
|
|
// fn is_immediately_bad(&self) -> bool {
|
|
|
|
// match self {
|
|
|
|
// DiffEntry::DiffResult(diff) => matches!(diff.status, DiffStatus::Bad),
|
|
|
|
// DiffEntry::DiffLayer(_) => false,
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
|
|
|
|
pub fn is_bad(&self) -> bool {
|
|
|
|
todo!()
|
|
|
|
// self.is_immediately_bad() || self.has_bad_children()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn print(&self, original_document: &str) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
self.print_indented(0, original_document)
|
|
|
|
}
|
|
|
|
|
|
|
|
fn print_indented(
|
|
|
|
&self,
|
|
|
|
indentation: usize,
|
|
|
|
original_document: &str,
|
|
|
|
) -> Result<(), Box<dyn std::error::Error>> {
|
|
|
|
todo!()
|
|
|
|
// match self {
|
|
|
|
// WasmDiffEntry::WasmDiffResult(diff) => {
|
|
|
|
// diff.print_indented(indentation, original_document)
|
|
|
|
// }
|
|
|
|
// WasmDiffEntry::WasmDiffLayer(diff) => {
|
|
|
|
// diff.print_indented(indentation, original_document)
|
|
|
|
// }
|
|
|
|
// }
|
|
|
|
}
|
|
|
|
}
|
2023-12-27 16:10:40 +00:00
|
|
|
|
|
|
|
fn wasm_compare_ast_node<'b, 's>(
|
|
|
|
source: &'s str,
|
|
|
|
emacs: &'b Token<'s>,
|
|
|
|
wasm: WasmAstNode<'s>,
|
|
|
|
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
|
|
|
match wasm {
|
|
|
|
WasmAstNode::Document(_) => todo!(),
|
|
|
|
WasmAstNode::Headline(_) => todo!(),
|
|
|
|
WasmAstNode::Section(_) => todo!(),
|
|
|
|
WasmAstNode::Paragraph(_) => todo!(),
|
|
|
|
WasmAstNode::PlainList(_) => todo!(),
|
|
|
|
WasmAstNode::PlainListItem(_) => todo!(),
|
|
|
|
WasmAstNode::CenterBlock(_) => todo!(),
|
|
|
|
WasmAstNode::QuoteBlock(_) => todo!(),
|
|
|
|
WasmAstNode::SpecialBlock(_) => todo!(),
|
|
|
|
WasmAstNode::DynamicBlock(_) => todo!(),
|
|
|
|
WasmAstNode::FootnoteDefinition(_) => todo!(),
|
|
|
|
WasmAstNode::Comment(_) => todo!(),
|
|
|
|
WasmAstNode::Drawer(_) => todo!(),
|
|
|
|
WasmAstNode::PropertyDrawer(_) => todo!(),
|
|
|
|
WasmAstNode::NodeProperty(_) => todo!(),
|
|
|
|
WasmAstNode::Table(_) => todo!(),
|
|
|
|
WasmAstNode::TableRow(_) => todo!(),
|
|
|
|
WasmAstNode::VerseBlock(_) => todo!(),
|
|
|
|
WasmAstNode::CommentBlock(_) => todo!(),
|
|
|
|
WasmAstNode::ExampleBlock(_) => todo!(),
|
|
|
|
WasmAstNode::ExportBlock(_) => todo!(),
|
|
|
|
WasmAstNode::SrcBlock(_) => todo!(),
|
|
|
|
WasmAstNode::Clock(_) => todo!(),
|
|
|
|
WasmAstNode::DiarySexp(_) => todo!(),
|
|
|
|
WasmAstNode::Planning(_) => todo!(),
|
|
|
|
WasmAstNode::FixedWidthArea(_) => todo!(),
|
|
|
|
WasmAstNode::HorizontalRule(_) => todo!(),
|
|
|
|
WasmAstNode::Keyword(_) => todo!(),
|
|
|
|
WasmAstNode::BabelCall(_) => todo!(),
|
|
|
|
WasmAstNode::LatexEnvironment(_) => todo!(),
|
|
|
|
WasmAstNode::Bold(_) => todo!(),
|
|
|
|
WasmAstNode::Italic(_) => todo!(),
|
|
|
|
WasmAstNode::Underline(_) => todo!(),
|
|
|
|
WasmAstNode::StrikeThrough(_) => todo!(),
|
|
|
|
WasmAstNode::Code(_) => todo!(),
|
|
|
|
WasmAstNode::Verbatim(_) => todo!(),
|
|
|
|
WasmAstNode::PlainText(_) => todo!(),
|
|
|
|
WasmAstNode::RegularLink(_) => todo!(),
|
|
|
|
WasmAstNode::RadioLink(_) => todo!(),
|
|
|
|
WasmAstNode::RadioTarget(_) => todo!(),
|
|
|
|
WasmAstNode::PlainLink(_) => todo!(),
|
|
|
|
WasmAstNode::AngleLink(_) => todo!(),
|
|
|
|
WasmAstNode::OrgMacro(_) => todo!(),
|
|
|
|
WasmAstNode::Entity(_) => todo!(),
|
|
|
|
WasmAstNode::LatexFragment(_) => todo!(),
|
|
|
|
WasmAstNode::ExportSnippet(_) => todo!(),
|
|
|
|
WasmAstNode::FootnoteReference(_) => todo!(),
|
|
|
|
WasmAstNode::Citation(_) => todo!(),
|
|
|
|
WasmAstNode::CitationReference(_) => todo!(),
|
|
|
|
WasmAstNode::InlineBabelCall(_) => todo!(),
|
|
|
|
WasmAstNode::InlineSourceBlock(_) => todo!(),
|
|
|
|
WasmAstNode::LineBreak(_) => todo!(),
|
|
|
|
WasmAstNode::Target(_) => todo!(),
|
|
|
|
WasmAstNode::StatisticsCookie(_) => todo!(),
|
|
|
|
WasmAstNode::Subscript(_) => todo!(),
|
|
|
|
WasmAstNode::Superscript(_) => todo!(),
|
|
|
|
WasmAstNode::TableCell(_) => todo!(),
|
|
|
|
WasmAstNode::Timestamp(_) => todo!(),
|
|
|
|
}
|
|
|
|
todo!()
|
|
|
|
}
|
|
|
|
|
|
|
|
fn impl_wasm_compare_document<'b, 's>(
|
|
|
|
source: &'s str,
|
|
|
|
emacs: &'b Token<'s>,
|
|
|
|
wasm: WasmDocument<'s>,
|
|
|
|
) -> Result<WasmDiffEntry<'b, 's>, Box<dyn std::error::Error>> {
|
|
|
|
todo!()
|
|
|
|
}
|