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
use crate::ns::*;
use serde::{Serialize, Deserialize};

#[derive(Clone, Serialize, Deserialize)]
pub struct ImportDirective {
    pub location: Location,
    pub alias: Option<(String, Location)>,
    pub package_name: Vec<(String, Location)>,
    pub import_specifier: ImportSpecifier,
}

#[derive(Clone, Serialize, Deserialize)]
pub enum ImportSpecifier {
    Wildcard(Location),
    Identifier((String, Location)),
}

impl ImportSpecifier {
    pub fn location(&self) -> Location {
        match self {
            Self::Wildcard(l) => l.clone(),
            Self::Identifier((_, l)) => l.clone(),
        }
    }
}