@@ -24,7 +24,7 @@ impl TypeLocation {
2424 pub fn to_type_naming_segments ( & self ) -> Vec < Vec < & str > > {
2525 match & self . root {
2626 TypeLocationRoot :: AgentConstructorInput { input_name } => {
27- let mut segments = vec ! [ vec![ "ConstructorInput " , input_name. as_str( ) ] ] ;
27+ let mut segments = vec ! [ vec![ "AgentParam " , input_name. as_str( ) ] ] ;
2828 if let Some ( path) = & self . path {
2929 segments. extend ( path. to_type_naming_segments ( ) ) ;
3030 }
@@ -34,7 +34,7 @@ impl TypeLocation {
3434 method_name,
3535 input_name,
3636 } => {
37- let mut segments = vec ! [ vec![ method_name. as_str( ) , "Input " , input_name. as_str( ) ] ] ;
37+ let mut segments = vec ! [ vec![ method_name. as_str( ) , "In " , input_name. as_str( ) ] ] ;
3838 if let Some ( path) = & self . path {
3939 segments. extend ( path. to_type_naming_segments ( ) ) ;
4040 }
@@ -44,7 +44,7 @@ impl TypeLocation {
4444 method_name,
4545 output_name,
4646 } => {
47- let mut segments = vec ! [ vec![ method_name. as_str( ) , "Output " , output_name. as_str( ) ] ] ;
47+ let mut segments = vec ! [ vec![ method_name. as_str( ) , "Out " , output_name. as_str( ) ] ] ;
4848 if let Some ( path) = & self . path {
4949 segments. extend ( path. to_type_naming_segments ( ) ) ;
5050 }
@@ -183,6 +183,7 @@ impl TypeLocationPath {
183183 if let Some ( name) = name {
184184 subsegments. push ( name. as_str ( ) ) ;
185185 }
186+ subsegments. push ( "Ok" ) ;
186187 segments. push ( subsegments) ;
187188 if let Some ( inner) = inner {
188189 collect ( segments, inner. as_ref ( ) ) ;
@@ -196,6 +197,7 @@ impl TypeLocationPath {
196197 if let Some ( name) = name {
197198 subsegments. push ( name. as_str ( ) ) ;
198199 }
200+ subsegments. push ( "Err" ) ;
199201 segments. push ( subsegments) ;
200202 if let Some ( inner) = inner {
201203 collect ( segments, inner. as_ref ( ) ) ;
@@ -370,3 +372,90 @@ impl Display for TypeLocationPath {
370372 Ok ( ( ) )
371373 }
372374}
375+
376+ #[ cfg( test) ]
377+ mod tests {
378+ use super :: { TypeLocation , TypeLocationPath , TypeLocationRoot } ;
379+ use test_r:: test;
380+
381+ #[ test]
382+ fn root_segments_use_short_in_out_suffixes ( ) {
383+ let constructor_in = TypeLocation {
384+ root : TypeLocationRoot :: AgentConstructorInput {
385+ input_name : "payload" . to_string ( ) ,
386+ } ,
387+ path : None ,
388+ } ;
389+ assert_eq ! (
390+ constructor_in. to_type_naming_segments( ) ,
391+ vec![ vec![ "AgentParam" , "payload" ] ]
392+ ) ;
393+
394+ let method_in = TypeLocation {
395+ root : TypeLocationRoot :: AgentMethodInput {
396+ method_name : "run" . to_string ( ) ,
397+ input_name : "request" . to_string ( ) ,
398+ } ,
399+ path : None ,
400+ } ;
401+ assert_eq ! (
402+ method_in. to_type_naming_segments( ) ,
403+ vec![ vec![ "run" , "In" , "request" ] ]
404+ ) ;
405+
406+ let method_out = TypeLocation {
407+ root : TypeLocationRoot :: AgentMethodOutput {
408+ method_name : "run" . to_string ( ) ,
409+ output_name : "response" . to_string ( ) ,
410+ } ,
411+ path : None ,
412+ } ;
413+ assert_eq ! (
414+ method_out. to_type_naming_segments( ) ,
415+ vec![ vec![ "run" , "Out" , "response" ] ]
416+ ) ;
417+ }
418+
419+ #[ test]
420+ fn result_path_segments_include_ok_and_err_markers ( ) {
421+ let ok_location = TypeLocation {
422+ root : TypeLocationRoot :: AgentMethodOutput {
423+ method_name : "run" . to_string ( ) ,
424+ output_name : "response" . to_string ( ) ,
425+ } ,
426+ path : Some ( TypeLocationPath :: ResultOk {
427+ name : Some ( "result" . to_string ( ) ) ,
428+ owner : Some ( "my-owner" . to_string ( ) ) ,
429+ inner : None ,
430+ } ) ,
431+ } ;
432+
433+ assert_eq ! (
434+ ok_location. to_type_naming_segments( ) ,
435+ vec![
436+ vec![ "run" , "Out" , "response" ] ,
437+ vec![ "my-owner" , "result" , "Ok" ]
438+ ]
439+ ) ;
440+
441+ let err_location = TypeLocation {
442+ root : TypeLocationRoot :: AgentMethodOutput {
443+ method_name : "run" . to_string ( ) ,
444+ output_name : "response" . to_string ( ) ,
445+ } ,
446+ path : Some ( TypeLocationPath :: ResultErr {
447+ name : Some ( "result" . to_string ( ) ) ,
448+ owner : Some ( "my-owner" . to_string ( ) ) ,
449+ inner : None ,
450+ } ) ,
451+ } ;
452+
453+ assert_eq ! (
454+ err_location. to_type_naming_segments( ) ,
455+ vec![
456+ vec![ "run" , "Out" , "response" ] ,
457+ vec![ "my-owner" , "result" , "Err" ]
458+ ]
459+ ) ;
460+ }
461+ }
0 commit comments