//! Code generation for enum errors

mod apollo;
mod display;
mod error;
mod from;
mod helpers;
mod registry;

use proc_macro2::TokenStream;
use quote::quote;

use crate::ir::EnumDefinition;

use apollo::generate_apollo_error_impl;
use display::generate_display_impl;
use error::generate_error_impl;
use from::generate_from_impls;
use registry::generate_registry_entry;

/// Generate all trait implementations for an enum error
pub(crate) fn generate_enum_impl(ir: &EnumDefinition) -> TokenStream {
    let display_impl = generate_display_impl(ir);
    let error_impl = generate_error_impl(ir);
    let apollo_error_impl = generate_apollo_error_impl(ir);
    let from_impls = generate_from_impls(ir);
    let registry_entry = generate_registry_entry(ir);

    quote! {
        #display_impl
        #error_impl
        #apollo_error_impl
        #from_impls
        #registry_entry
    }
}
