mxmlextrema_as3parser/tree/
reserved_namespace_expression.rs

1use crate::ns::*;
2use serde::{Serialize, Deserialize};
3
4#[derive(Debug, Clone, Serialize, Deserialize)]
5pub enum ReservedNamespaceExpression {
6    Public(Location),
7    Private(Location),
8    Protected(Location),
9    Internal(Location),
10}
11
12impl ReservedNamespaceExpression {
13    pub fn location(&self) -> Location {
14        match self {
15            Self::Public(l) => l.clone(),
16            Self::Private(l) => l.clone(),
17            Self::Protected(l) => l.clone(),
18            Self::Internal(l) => l.clone(),
19        }
20    }
21
22    pub fn to_attribute(&self) -> Attribute {
23        match self {
24            Self::Public(l) => Attribute::Public(l.clone()),
25            Self::Private(l) => Attribute::Private(l.clone()),
26            Self::Protected(l) => Attribute::Protected(l.clone()),
27            Self::Internal(l) => Attribute::Internal(l.clone()),
28        }
29    }
30}
31
32impl ToString for ReservedNamespaceExpression {
33    fn to_string(&self) -> String {
34        match self {
35            Self::Public(_) => "public".into(),
36            Self::Private(_) => "private".into(),
37            Self::Protected(_) => "protected".into(),
38            Self::Internal(_) => "internal".into(),
39        }
40    }
41}