aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/validation.rs
blob: bdee8120c91cec63c794ee364027559ed52fe60f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
use crate::{
    algo::visit::{visitor_ctx, VisitorCtx},
    ast,
    SourceFileNode,
    yellow::SyntaxError,
};

mod byte;
mod byte_string;
mod char;
mod string;

pub(crate) fn validate(file: &SourceFileNode) -> Vec<SyntaxError> {
    let mut errors = Vec::new();
    for node in file.syntax().descendants() {
        let _ = visitor_ctx(&mut errors)
            .visit::<ast::Byte, _>(self::byte::validate_byte_node)
            .visit::<ast::ByteString, _>(self::byte_string::validate_byte_string_node)
            .visit::<ast::Char, _>(self::char::validate_char_node)
            .visit::<ast::String, _>(self::string::validate_string_node)
            .accept(node);
    }
    errors
}