aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_syntax/src/validation.rs
blob: ac6cc3dd613e032759d1be764d5a40272e296acb (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
25
mod byte;
mod byte_string;
mod char;
mod string;
mod block;

use crate::{
    SourceFile, yellow::SyntaxError, AstNode,
    ast,
    algo::visit::{visitor_ctx, VisitorCtx},
};

pub(crate) fn validate(file: &SourceFile) -> 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)
            .visit::<ast::Block, _>(self::block::validate_block_node)
            .accept(node);
    }
    errors
}