diff options
Diffstat (limited to 'crates/ra_syntax')
-rw-r--r-- | crates/ra_syntax/src/lib.rs | 12 | ||||
-rw-r--r-- | crates/ra_syntax/tests/test.rs | 4 |
2 files changed, 12 insertions, 4 deletions
diff --git a/crates/ra_syntax/src/lib.rs b/crates/ra_syntax/src/lib.rs index 9790a984d..06d3ea727 100644 --- a/crates/ra_syntax/src/lib.rs +++ b/crates/ra_syntax/src/lib.rs | |||
@@ -59,11 +59,19 @@ pub use rowan::{SmolStr, TextRange, TextUnit}; | |||
59 | /// files. | 59 | /// files. |
60 | #[derive(Debug, Clone, PartialEq, Eq)] | 60 | #[derive(Debug, Clone, PartialEq, Eq)] |
61 | pub struct Parse { | 61 | pub struct Parse { |
62 | pub tree: TreeArc<SourceFile>, | 62 | tree: TreeArc<SourceFile>, |
63 | pub errors: Arc<Vec<SyntaxError>>, | 63 | errors: Arc<Vec<SyntaxError>>, |
64 | } | 64 | } |
65 | 65 | ||
66 | impl Parse { | 66 | impl Parse { |
67 | pub fn tree(&self) -> &SourceFile { | ||
68 | &*self.tree | ||
69 | } | ||
70 | |||
71 | pub fn errors(&self) -> &[SyntaxError] { | ||
72 | &*self.errors | ||
73 | } | ||
74 | |||
67 | pub fn ok(self) -> Result<TreeArc<SourceFile>, Arc<Vec<SyntaxError>>> { | 75 | pub fn ok(self) -> Result<TreeArc<SourceFile>, Arc<Vec<SyntaxError>>> { |
68 | if self.errors.is_empty() { | 76 | if self.errors.is_empty() { |
69 | Ok(self.tree) | 77 | Ok(self.tree) |
diff --git a/crates/ra_syntax/tests/test.rs b/crates/ra_syntax/tests/test.rs index 2442c8505..cabd3e9bd 100644 --- a/crates/ra_syntax/tests/test.rs +++ b/crates/ra_syntax/tests/test.rs | |||
@@ -22,7 +22,7 @@ fn lexer_tests() { | |||
22 | fn parser_tests() { | 22 | fn parser_tests() { |
23 | dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { | 23 | dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { |
24 | let parse = SourceFile::parse(text); | 24 | let parse = SourceFile::parse(text); |
25 | let errors = parse.errors.as_slice(); | 25 | let errors = parse.errors(); |
26 | assert_eq!( | 26 | assert_eq!( |
27 | errors, | 27 | errors, |
28 | &[] as &[ra_syntax::SyntaxError], | 28 | &[] as &[ra_syntax::SyntaxError], |
@@ -33,7 +33,7 @@ fn parser_tests() { | |||
33 | }); | 33 | }); |
34 | dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], |text, path| { | 34 | dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], |text, path| { |
35 | let parse = SourceFile::parse(text); | 35 | let parse = SourceFile::parse(text); |
36 | let errors = parse.errors.as_slice(); | 36 | let errors = parse.errors(); |
37 | assert!(!errors.is_empty(), "There should be errors in the file {:?}", path.display()); | 37 | assert!(!errors.is_empty(), "There should be errors in the file {:?}", path.display()); |
38 | parse.debug_dump() | 38 | parse.debug_dump() |
39 | }); | 39 | }); |