use proc_macro2::TokenStream as TokenStream2;
use quote::quote;
use crate::parser::command_spec::{unchecked::DeriveValue, Attribute, Identifier};
impl Attribute {
pub fn to_rust(&self, _target: &Identifier) -> TokenStream2 {
match self {
Attribute::doc(comment) => comment
.split('\n')
.map(|com| quote! { #[doc = #com] })
.collect::<TokenStream2>(),
Attribute::error(msg) => quote! {
#[error(#msg)]
},
Attribute::derive(attr) => {
match attr {
DeriveValue::Error => quote! {
#[derive(trixy::__private::thiserror::Error)]
},
}
}
}
}
}