use proc_macro2::Span;
use syn::spanned::Spanned;
use syn::{Expr, Ident, LitStr, Path};
pub struct Root(pub Vec<Node>);
pub enum Node {
Tag(TagNode),
Text(TextNode),
Dyn(DynNode),
}
pub enum NodeType {
Tag,
Text,
Dyn,
}
pub struct TagNode {
pub ident: TagIdent,
pub props: Vec<Prop>,
pub children: Root,
}
pub enum TagIdent {
Path(Path),
Hyphenated(String),
}
impl TagIdent {
pub fn span(&self) -> Span {
match self {
Self::Path(path) => path.span(),
Self::Hyphenated(_) => Span::call_site(),
}
}
}
pub struct Prop {
pub ty: PropType,
pub value: Expr,
pub span: Span,
}
pub enum PropType {
Plain { ident: Ident },
PlainHyphenated { ident: String },
PlainQuoted { ident: String },
Directive { dir: Ident, ident: Ident },
Ref,
Spread,
}
pub struct TextNode {
pub value: LitStr,
}
pub struct DynNode {
pub value: Expr,
}