mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-27 22:09:09 +00:00
basic highlighting flow using MarkupNodes
This commit is contained in:
parent
853badf777
commit
37704323b1
16 changed files with 269 additions and 301 deletions
|
@ -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 }
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue