@@ -6,9 +6,13 @@ use cafebabe::descriptors::{FieldDescriptor, FieldType, ReturnDescriptor};
66use super :: classes:: Class ;
77use super :: methods:: Method ;
88use crate :: emit:: Context ;
9+ use crate :: util;
910
1011impl Class {
11- pub ( crate ) fn write_java_proxy ( & self , context : & Context , methods : & [ Method ] ) -> anyhow:: Result < String > {
12+ pub ( crate ) fn write_java_proxy ( & self , context : & Context ) -> anyhow:: Result < String > {
13+ // Collect methods for this class
14+ let methods: Vec < Method > = self . java . methods ( ) . map ( |m| Method :: new ( & self . java , m) ) . collect ( ) ;
15+
1216 let java_proxy_path = format ! (
1317 "{}/{}" ,
1418 context. config. proxy_package,
@@ -172,27 +176,16 @@ pub fn write_java_proxy_files(context: &Context, output_dir: &Path) -> anyhow::R
172176 continue ;
173177 }
174178
175- // Collect methods for this class
176- let mut methods = Vec :: new ( ) ;
177- methods. extend ( class. java . methods ( ) . map ( |m| Method :: new ( & class. java , m) ) ) ;
178-
179- let java_code = class. write_java_proxy ( context, & methods) ?;
179+ let java_code = class. write_java_proxy ( context) ?;
180180
181181 // Calculate output file path
182182 let java_proxy_path = class. java . path ( ) . as_str ( ) . replace ( "$" , "_" ) ;
183183
184184 let relative_path = format ! ( "{java_proxy_path}.java" ) ;
185185 let output_file = output_dir. join ( & relative_path) ;
186186
187- // Create directory if it doesn't exist
188- if let Some ( parent) = output_file. parent ( ) {
189- std:: fs:: create_dir_all ( parent) ?;
190- }
191-
192187 // Write Java file
193- std:: fs:: write ( & output_file, java_code) ?;
194-
195- println ! ( "Generated Java proxy: {}" , output_file. display( ) ) ;
188+ util:: write_generated ( context, & output_file, java_code. as_bytes ( ) ) ?;
196189 }
197190
198191 Ok ( ( ) )
0 commit comments