diff options
Diffstat (limited to 'crates/ra_syntax/src/validation/mod.rs')
-rw-r--r-- | crates/ra_syntax/src/validation/mod.rs | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/crates/ra_syntax/src/validation/mod.rs b/crates/ra_syntax/src/validation/mod.rs new file mode 100644 index 000000000..2ff0bc26d --- /dev/null +++ b/crates/ra_syntax/src/validation/mod.rs | |||
@@ -0,0 +1,20 @@ | |||
1 | use crate::{ | ||
2 | algo::visit::{visitor_ctx, VisitorCtx}, | ||
3 | ast, | ||
4 | SourceFileNode, | ||
5 | yellow::SyntaxError, | ||
6 | }; | ||
7 | |||
8 | mod char; | ||
9 | mod string; | ||
10 | |||
11 | pub(crate) fn validate(file: &SourceFileNode) -> Vec<SyntaxError> { | ||
12 | let mut errors = Vec::new(); | ||
13 | for node in file.syntax().descendants() { | ||
14 | let _ = visitor_ctx(&mut errors) | ||
15 | .visit::<ast::Char, _>(self::char::validate_char_node) | ||
16 | .visit::<ast::String, _>(self::string::validate_string_node) | ||
17 | .accept(node); | ||
18 | } | ||
19 | errors | ||
20 | } | ||