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
26
27
28
29
30
31
32
33
34
use rowan::GreenNode;

use crate::util::LineMap;

use super::{Error, SyntaxNode};

#[derive(Debug, Clone)]
pub struct Ast {
    green_node: GreenNode,
    errors: Vec<Error>,
    line_map: LineMap,
}

impl Ast {
    pub fn new(green_node: GreenNode, errors: Vec<Error>, line_map: LineMap) -> Self {
        Self {
            green_node,
            errors,
            line_map,
        }
    }

    pub fn into_inner(self) -> (SyntaxNode, Vec<Error>, LineMap) {
        (
            SyntaxNode::new_root(self.green_node),
            self.errors,
            self.line_map,
        )
    }

    pub fn green_node(&self) -> &GreenNode {
        &self.green_node
    }
}