basic highlighting flow using MarkupNodes

This commit is contained in:
Anton-4 2022-03-04 20:19:05 +01:00
parent 853badf777
commit 37704323b1
No known key found for this signature in database
GPG key ID: C954D6E0F9C0ABFD
16 changed files with 269 additions and 301 deletions

View file

@ -1,7 +1,8 @@
use peg::error::ParseError;
use roc_ast::ast_error::ASTError;
use roc_module::module_err::ModuleError;
use roc_parse::parser::SyntaxError;
use snafu::{NoneError, ResultExt, Snafu};
use snafu::{Snafu};
#[derive(Debug, Snafu)]
#[snafu(visibility(pub))]
@ -18,17 +19,16 @@ pub enum DocsError {
WrapSyntaxError {
msg: String,
},
WrapPegParseError {
source: ParseError<usize>,
},
}
pub type DocsResult<T, E = DocsError> = std::result::Result<T, E>;
impl<'a> From<SyntaxError<'a>> for DocsError {
fn from(syntax_err: SyntaxError) -> Self {
let msg = format!("{:?}", syntax_err);
// hack to handle MarkError derive
let dummy_res: Result<(), NoneError> = Err(NoneError {});
dummy_res.context(WrapSyntaxError { msg }).unwrap_err()
Self::WrapSyntaxError { msg: format!("{:?}", syntax_err) }
}
}
@ -43,3 +43,9 @@ impl From<ModuleError> for DocsError {
Self::WrapModuleError { source: module_err }
}
}
impl From<ParseError<usize>> for DocsError {
fn from(peg_parse_err: ParseError<usize>) -> Self {
Self::WrapPegParseError { source: peg_parse_err }
}
}