<commit_before>extern crate proc_macro;
extern crate proc_macro2;
extern crate syn;

use crate::proc_macro::TokenStream;
use quote::quote;

fn derive_using_macro(input: TokenStream, macro_name: proc_macro2::TokenStream) -> TokenStream {
    let input: syn::Item = syn::parse(input).expect("Invalid syntax");
    let output = quote!(
        #macro_name ! {
            #input
        }
    );
    output.into()
}

#[proc_macro_derive(GraphQLNewtype)]
pub fn newtype_derive(input: TokenStream) -> TokenStream {
    derive_using_macro(input, quote!(graphql_newtype))
}

#[proc_macro_derive(GraphQLObjectFromUnit)]
pub fn object_from_unit_derive(input: TokenStream) -> TokenStream {
    derive_using_macro(input, quote!(graphql_object_from_unit))
}

#[proc_macro_derive(GraphQLUnionFromEnum)]
pub fn union_from_enum_derive(input: TokenStream) -> TokenStream {
    derive_using_macro(input, quote!(graphql_union_from_enum))
}

#[proc_macro_attribute]
pub fn graphql(_attr: TokenStream, input: TokenStream) -> TokenStream {
    let input: syn::Item = syn::parse(input).expect("Invalid syntax");
    let output = quote!(
        #input

        #[juniper::object]<commit_msg>Allow dead code in `#[juniper_ext::graphql] impl`<commit_after>extern crate proc_macro;
extern crate proc_macro2;
extern crate syn;

use crate::proc_macro::TokenStream;
use quote::quote;

fn derive_using_macro(input: TokenStream, macro_name: proc_macro2::TokenStream) -> TokenStream {
    let input: syn::Item = syn::parse(input).expect("Invalid syntax");
    let output = quote!(
        #macro_name ! {
            #input
        }
    );
    output.into()
}

#[proc_macro_derive(GraphQLNewtype)]
pub fn newtype_derive(input: TokenStream) -> TokenStream {
    derive_using_macro(input, quote!(graphql_newtype))
}

#[proc_macro_derive(GraphQLObjectFromUnit)]
pub fn object_from_unit_derive(input: TokenStream) -> TokenStream {
    derive_using_macro(input, quote!(graphql_object_from_unit))
}

#[proc_macro_derive(GraphQLUnionFromEnum)]
pub fn union_from_enum_derive(input: TokenStream) -> TokenStream {
    derive_using_macro(input, quote!(graphql_union_from_enum))
}

#[proc_macro_attribute]
pub fn graphql(_attr: TokenStream, input: TokenStream) -> TokenStream {
    let input: syn::Item = syn::parse(input).expect("Invalid syntax");
    let output = quote!(
        #[allow(dead_code)]
        #input

        #[juniper::object]
{'fraction_non_alphanumeric': 0.12156536219816819, 'fraction_numerical': 0.0016652789342214821, 'mean_word_length': 5.145780051150895, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3848127', 'n_tokens_mistral': 787, 'n_tokens_neox': 782, 'n_words': 149}