teo_parser/ast/
import.rs

1use crate::ast::literals::StringLiteral;
2use crate::ast::span::Span;
3use crate::{declare_node, impl_node_defaults};
4use crate::format::Writer;
5use crate::traits::write::Write;
6
7declare_node!(Import,
8    pub source: StringLiteral,
9    pub file_path: String,
10);
11
12impl_node_defaults!(Import);
13
14impl Import {
15
16    pub fn new(path: Vec<usize>, source: StringLiteral, file_path: String, span: Span) -> Self {
17        Self {
18            path,
19            source,
20            file_path,
21            span,
22        }
23    }
24}
25
26impl Write for Import {
27    fn write<'a>(&'a self, writer: &mut Writer<'a>) {
28        writer.write_contents(self, vec!["import ", self.source.display.as_str()])
29    }
30
31    fn always_start_on_new_line(&self) -> bool {
32        true
33    }
34
35    fn always_end_on_new_line(&self) -> bool {
36        true
37    }
38}