aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/ast/mod.rs6
-rw-r--r--src/lib.rs2
-rw-r--r--src/utils.rs4
-rw-r--r--src/yellow/builder.rs2
-rw-r--r--src/yellow/mod.rs3
-rw-r--r--src/yellow/syntax.rs6
6 files changed, 13 insertions, 10 deletions
diff --git a/src/ast/mod.rs b/src/ast/mod.rs
index 317ed4f45..eeb7ae6f6 100644
--- a/src/ast/mod.rs
+++ b/src/ast/mod.rs
@@ -2,7 +2,7 @@ mod generated;
2 2
3use std::sync::Arc; 3use std::sync::Arc;
4use { 4use {
5 SyntaxNode, SyntaxRoot, TreeRoot, 5 SyntaxNode, SyntaxRoot, TreeRoot, SyntaxError,
6 SyntaxKind::*, 6 SyntaxKind::*,
7}; 7};
8pub use self::generated::*; 8pub use self::generated::*;
@@ -19,6 +19,10 @@ impl File<Arc<SyntaxRoot>> {
19} 19}
20 20
21impl<R: TreeRoot> File<R> { 21impl<R: TreeRoot> File<R> {
22 pub fn errors(&self) -> Vec<SyntaxError> {
23 self.syntax().root.errors.clone()
24 }
25
22 pub fn functions<'a>(&'a self) -> impl Iterator<Item = Function<R>> + 'a { 26 pub fn functions<'a>(&'a self) -> impl Iterator<Item = Function<R>> + 'a {
23 self.syntax() 27 self.syntax()
24 .children() 28 .children()
diff --git a/src/lib.rs b/src/lib.rs
index d1e690bb2..ca33618a0 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -45,7 +45,7 @@ pub use {
45 lexer::{tokenize, Token}, 45 lexer::{tokenize, Token},
46 syntax_kinds::SyntaxKind, 46 syntax_kinds::SyntaxKind,
47 text_unit::{TextRange, TextUnit}, 47 text_unit::{TextRange, TextUnit},
48 yellow::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot}, 48 yellow::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot, SyntaxError},
49}; 49};
50 50
51 51
diff --git a/src/utils.rs b/src/utils.rs
index a23a57423..1fbb872a5 100644
--- a/src/utils.rs
+++ b/src/utils.rs
@@ -29,7 +29,7 @@ pub fn dump_tree(syntax: &SyntaxNode) -> String {
29 let off = node.range().end(); 29 let off = node.range().end();
30 while err_pos < errors.len() && errors[err_pos].offset <= off { 30 while err_pos < errors.len() && errors[err_pos].offset <= off {
31 indent!(); 31 indent!();
32 writeln!(buf, "err: `{}`", errors[err_pos].message).unwrap(); 32 writeln!(buf, "err: `{}`", errors[err_pos].msg).unwrap();
33 err_pos += 1; 33 err_pos += 1;
34 } 34 }
35 } 35 }
@@ -41,7 +41,7 @@ pub fn dump_tree(syntax: &SyntaxNode) -> String {
41 41
42 assert_eq!(level, 0); 42 assert_eq!(level, 0);
43 for err in errors[err_pos..].iter() { 43 for err in errors[err_pos..].iter() {
44 writeln!(buf, "err: `{}`", err.message).unwrap(); 44 writeln!(buf, "err: `{}`", err.msg).unwrap();
45 } 45 }
46 46
47 return buf; 47 return buf;
diff --git a/src/yellow/builder.rs b/src/yellow/builder.rs
index 878f3ba39..5e94e5055 100644
--- a/src/yellow/builder.rs
+++ b/src/yellow/builder.rs
@@ -51,7 +51,7 @@ impl<'a> Sink<'a> for GreenBuilder<'a> {
51 51
52 fn error(&mut self, message: String) { 52 fn error(&mut self, message: String) {
53 self.errors.push(SyntaxError { 53 self.errors.push(SyntaxError {
54 message, 54 msg: message,
55 offset: self.pos, 55 offset: self.pos,
56 }) 56 })
57 } 57 }
diff --git a/src/yellow/mod.rs b/src/yellow/mod.rs
index 1b5d4e4df..6129ecb99 100644
--- a/src/yellow/mod.rs
+++ b/src/yellow/mod.rs
@@ -3,10 +3,9 @@ mod green;
3mod red; 3mod red;
4mod syntax; 4mod syntax;
5 5
6pub use self::syntax::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot}; 6pub use self::syntax::{SyntaxNode, SyntaxNodeRef, SyntaxRoot, TreeRoot, SyntaxError};
7pub(crate) use self::{ 7pub(crate) use self::{
8 builder::GreenBuilder, 8 builder::GreenBuilder,
9 green::GreenNode, 9 green::GreenNode,
10 red::RedNode, 10 red::RedNode,
11 syntax::SyntaxError,
12}; 11};
diff --git a/src/yellow/syntax.rs b/src/yellow/syntax.rs
index 07607ec2d..2ba9281fc 100644
--- a/src/yellow/syntax.rs
+++ b/src/yellow/syntax.rs
@@ -46,9 +46,9 @@ impl SyntaxRoot {
46} 46}
47 47
48#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)] 48#[derive(Debug, Clone, PartialEq, Eq, Hash, Ord, PartialOrd)]
49pub(crate) struct SyntaxError { 49pub struct SyntaxError {
50 pub(crate) message: String, 50 pub msg: String,
51 pub(crate) offset: TextUnit, 51 pub offset: TextUnit,
52} 52}
53 53
54impl SyntaxNode<Arc<SyntaxRoot>> { 54impl SyntaxNode<Arc<SyntaxRoot>> {