@@ -16,6 +16,8 @@ pub fn message_handler_data_attr_impl(attr: TokenStream, input_item: TokenStream
1616
1717 let input_type = path. segments . last ( ) . map ( |s| & s. ident ) . unwrap ( ) ;
1818
19+ let handler_line_number = input_type. span ( ) . start ( ) . line ;
20+
1921 // Extract the message type from the trait path
2022 let trait_path = match & impl_block. trait_ {
2123 Some ( ( _, path, _) ) => path,
@@ -40,14 +42,16 @@ pub fn message_handler_data_attr_impl(attr: TokenStream, input_item: TokenStream
4042 // Get just the base identifier (ToolMessageData) without generics
4143 let type_name = & type_path. path . segments . first ( ) . unwrap ( ) . ident ;
4244
45+ let handler_data_line_number = type_name. span ( ) . start ( ) . line ;
46+
4347 quote ! {
4448 #input_item
4549 impl #message_type {
4650 pub fn message_handler_data_str( ) -> MessageData {
47- MessageData :: new( format!( "{}" , stringify!( #type_name) ) , #type_name:: field_types( ) , #type_name:: path( ) )
51+ MessageData :: new( format!( "{}" , stringify!( #type_name) ) , #type_name:: field_types( ) , #type_name:: path( ) , #type_name :: line_number ( ) )
4852 }
4953 pub fn message_handler_str( ) -> MessageData {
50- MessageData :: new( format!( "{}" , stringify!( #input_type) ) , #input_type:: field_types( ) , #input_type:: path( ) )
54+ MessageData :: new( format!( "{}" , stringify!( #input_type) ) , #input_type:: field_types( ) , #input_type:: path( ) , #input_type :: line_number ( ) )
5155
5256 }
5357 }
@@ -57,7 +61,7 @@ pub fn message_handler_data_attr_impl(attr: TokenStream, input_item: TokenStream
5761 #input_item
5862 impl #message_type {
5963 pub fn message_handler_str( ) -> MessageData {
60- MessageData :: new( format!( "{}" , stringify!( #input_type) ) , #input_type:: field_types( ) , #input_type:: path( ) )
64+ MessageData :: new( format!( "{}" , stringify!( #input_type) ) , #input_type:: field_types( ) , #input_type:: path( ) , #input_type :: line_number ( ) )
6165 }
6266 }
6367 } ,
@@ -67,16 +71,19 @@ pub fn message_handler_data_attr_impl(attr: TokenStream, input_item: TokenStream
6771 syn:: Type :: Path ( type_path) => & type_path. path . segments . first ( ) . unwrap ( ) . ident ,
6872 _ => return Err ( syn:: Error :: new ( type_reference. elem . span ( ) , "Expected type path" ) ) ,
6973 } ;
74+
75+ let type_line_number = type_ident. span ( ) . start ( ) . line ;
76+
7077 let tr = clean_rust_type_syntax ( type_reference. to_token_stream ( ) . to_string ( ) ) ;
7178 quote ! {
7279 #input_item
7380 impl #message_type {
7481 pub fn message_handler_data_str( ) -> MessageData {
75- MessageData :: new( format!( "{}" , #tr) , #type_ident:: field_types( ) , #type_ident:: path( ) )
82+ MessageData :: new( format!( "{}" , #tr) , #type_ident:: field_types( ) , #type_ident:: path( ) , #type_ident :: line_number ( ) )
7683 }
7784
7885 pub fn message_handler_str( ) -> MessageData {
79- MessageData :: new( format!( "{}" , stringify!( #input_type) ) , #input_type:: field_types( ) , #input_type:: path( ) )
86+ MessageData :: new( format!( "{}" , stringify!( #input_type) ) , #input_type:: field_types( ) , #input_type:: path( ) , #input_type :: line_number ( ) )
8087
8188 }
8289 }
0 commit comments