1use std::ops::Range;
2
3pub trait RowanNomError<Lang: super::Language> {
4 fn from_message(message: &str) -> Self;
6
7 fn from_expected(position: usize, message: &str) -> Self;
8
9 fn from_expected_eof(range: Range<usize>) -> Self;
10
11 fn from_unexpected_eof(position: usize) -> Self;
13
14 fn from_unexpected_token(span: Range<usize>, expected: Lang::Kind, found: Lang::Kind) -> Self;
15
16 fn with_context(self, ctx: &'static str) -> Self;
17
18 }
20
21#[derive(Debug, Default, Clone, Copy, thiserror::Error)]
23#[error("dummy error used, can't provide further information")]
24pub struct DummyError;
25
26impl<Lang: super::Language> RowanNomError<Lang> for DummyError {
27 fn from_message(_message: &str) -> Self {
28 Self
29 }
30
31 fn from_expected(_position: usize, _message: &str) -> Self {
32 Self
33 }
34
35 fn from_expected_eof(_range: Range<usize>) -> Self {
36 Self
37 }
38
39 fn from_unexpected_eof(_position: usize) -> Self {
40 Self
41 }
42
43 fn from_unexpected_token(
44 _span: Range<usize>,
45 _expected: Lang::Kind,
46 _found: Lang::Kind,
47 ) -> Self {
48 Self
49 }
50
51 fn with_context(self, _ctx: &'static str) -> Self {
52 Self
53 }
54}