<commit_before>// vim: tw=80
use super::*;

use quote::ToTokens;

use crate::mock_function::MockFunction;



pub(crate) struct MockItemStruct {
    generics: Generics,
    /// Inherent methods of the mock struct
    methods: Vec<MockFunction>,
    name: Ident,
    //traits: Vec<MockTraitImpl>
    vis: Visibility,
}

impl From<MockableStruct> for MockItemStruct {
    fn from(mockable: MockableStruct) -> MockItemStruct {
        let mock_ident = gen_mod_ident(&mockable.name, None);
        let methods = Vec::new();
        //let methods = mockable.methods.into_iter()
            //.map(|meth| MockFunction::from((&mock_ident, 1, meth)))
            //.collect::<Vec<_>>();
        MockItemStruct {
            generics: mockable.generics,
            methods,
            name: mockable.name,
            //traits: Vec::new()
            vis: mockable.vis
        }
    }
}

impl ToTokens for MockItemStruct {
    fn to_tokens(&self, tokens: &mut TokenStream) {
        let struct_name = &self.name;
        let (ig, tg, wc) = self.generics.split_for_impl(); //TODO
        let vis = &self.vis;
        let mut default_body = TokenStream::new();  // TODO
        quote!(
            //#[allow(non_snake_case)]
            //#[doc(hidden)]
            //pub mod mod_ident {
                //use super::*;
                ////mod_body
            //}
            #[allow(non_camel_case_types)]
            #[allow(non_snake_case)]<commit_msg>WIP mocking structs<commit_after>// vim: tw=80
use super::*;

use quote::ToTokens;

use crate::mock_function::MockFunction;



pub(crate) struct MockItemStruct {
    generics: Generics,
    /// Inherent methods of the mock struct
    methods: Vec<MockFunction>,
    name: Ident,
    //traits: Vec<MockTraitImpl>
    vis: Visibility,
}

impl From<MockableStruct> for MockItemStruct {
    fn from(mockable: MockableStruct) -> MockItemStruct {
        let mock_ident = gen_mod_ident(&mockable.name, None);
        let vis = Visibility::Public(VisPublic{
            pub_token: Token![pub](Span::call_site())
        });
        let methods = mockable.methods.into_iter()
            .map(|meth|
                MockFunction::from((&mock_ident, 1, meth.sig, vis.clone()))
            ).collect::<Vec<_>>();
        MockItemStruct {
            generics: mockable.generics,
            methods,
            name: mockable.name,
            //traits: Vec::new()
            vis: mockable.vis
        }
    }
}

impl ToTokens for MockItemStruct {
    fn to_tokens(&self, tokens: &mut TokenStream) {
        let struct_name = &self.name;
        let (ig, tg, wc) = self.generics.split_for_impl(); //TODO
        let methods = &self.methods;
        let vis = &self.vis;
        let mut default_body = TokenStream::new();  // TODO
        quote!(
            #[allow(non_snake_case)]
            #[doc(hidden)]
            pub mod mod_ident {
                use super::*;
                #(#methods)*
                //mod_body
            }
            #[allow(non_camel_case_types)]
            #[allow(non_snake_case)]
{'fraction_non_alphanumeric': 0.13076168682576006, 'fraction_numerical': 0.001961425302386401, 'mean_word_length': 2.026706231454006, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 15, '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': '4611276', 'n_tokens_mistral': 941, 'n_tokens_neox': 931, 'n_words': 204}