From deab4caa7b1ba81c1b7e6561bc270bbde6467f13 Mon Sep 17 00:00:00 2001 From: Aleksey Kladov Date: Fri, 12 Jul 2019 19:41:13 +0300 Subject: make Parse fields private this is in preparation for the new rowan API --- crates/ra_syntax/src/lib.rs | 12 ++++++++++-- crates/ra_syntax/tests/test.rs | 4 ++-- 2 files changed, 12 insertions(+), 4 deletions(-) (limited to 'crates/ra_syntax') 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}; /// files. #[derive(Debug, Clone, PartialEq, Eq)] pub struct Parse { - pub tree: TreeArc, - pub errors: Arc>, + tree: TreeArc, + errors: Arc>, } impl Parse { + pub fn tree(&self) -> &SourceFile { + &*self.tree + } + + pub fn errors(&self) -> &[SyntaxError] { + &*self.errors + } + pub fn ok(self) -> Result, Arc>> { if self.errors.is_empty() { 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() { fn parser_tests() { dir_tests(&test_data_dir(), &["parser/inline/ok", "parser/ok"], |text, path| { let parse = SourceFile::parse(text); - let errors = parse.errors.as_slice(); + let errors = parse.errors(); assert_eq!( errors, &[] as &[ra_syntax::SyntaxError], @@ -33,7 +33,7 @@ fn parser_tests() { }); dir_tests(&test_data_dir(), &["parser/err", "parser/inline/err"], |text, path| { let parse = SourceFile::parse(text); - let errors = parse.errors.as_slice(); + let errors = parse.errors(); assert!(!errors.is_empty(), "There should be errors in the file {:?}", path.display()); parse.debug_dump() }); -- cgit v1.2.3