#![allow(unused)]

use std::fmt::Display;

use proc_macro2::{Span, TokenStream};
use quote::quote;
use syn::Ident;


pub(crate) fn convert_string_to_identifier(string: &str) -> Ident {
    let identifier = string.replace(['-', '.'], "_");
    Ident::new(&identifier, Span::call_site())
}


pub(crate) fn template_display_impl(implementee: &Ident, values: &[(Ident, impl Display)]) -> TokenStream {

    let match_lines = values.iter()
        .map(|(ident, value)| {
            let value = value.to_string();
            quote! {
                Self::#ident => #value,
            }
        })
        .collect::<TokenStream>();

    quote! {
        impl ::std::fmt::Display for #implementee {
            fn fmt(&self, f: &mut ::std::fmt::Formatter<'_>) -> ::std::fmt::Result {
                let string = match self {
                    #match_lines
                };

                f.write_str(string)
            }
        }
    }
}
