@@ -118,10 +118,10 @@ pub struct FunctionAnalysis {
118118#[ derive( Debug , Serialize ) ]
119119pub struct FunctionMatch {
120120 pub id : String ,
121- pub source_function : FunctionInfo ,
121+ pub source_function : Option < FunctionInfo > ,
122122 pub target_function : Option < FunctionInfo > ,
123123 pub similarity : SimilarityScore ,
124- pub change_type : String ,
124+ pub match_type : String ,
125125 pub refactoring_pattern : Option < RefactoringPattern > ,
126126}
127127
@@ -135,6 +135,8 @@ pub struct FunctionInfo {
135135 pub complexity : usize ,
136136 pub parameters : Vec < String > ,
137137 pub return_type : String ,
138+ pub content : String ,
139+ pub file_path : String ,
138140}
139141
140142/// Change analysis
@@ -635,3 +637,74 @@ pub struct WatchFilesResponse {
635637 pub paths : Vec < String > ,
636638 pub message : String ,
637639}
640+
641+ // AST Diff Models
642+ #[ derive( Debug , Serialize , Deserialize ) ]
643+ pub struct ASTDiffRequest {
644+ pub source_content : String ,
645+ pub target_content : String ,
646+ pub source_file_path : String ,
647+ pub target_file_path : String ,
648+ pub language : String ,
649+ pub options : ASTDiffOptions ,
650+ }
651+
652+ #[ derive( Debug , Serialize , Deserialize ) ]
653+ pub struct ASTDiffOptions {
654+ pub enable_semantic_analysis : bool ,
655+ pub enable_structural_analysis : bool ,
656+ pub generate_line_mapping : bool ,
657+ /// Diff algorithm: "lcs" (fast, line-based) or "ast" (slow, structure-aware)
658+ #[ serde( default = "default_diff_algorithm" ) ]
659+ pub diff_algorithm : String ,
660+ /// Use Zhang-Shasha tree edit distance for AST comparison
661+ #[ serde( default ) ]
662+ pub use_tree_edit_distance : bool ,
663+ /// Use Hungarian algorithm for optimal node matching
664+ #[ serde( default ) ]
665+ pub use_hungarian_matching : bool ,
666+ }
667+
668+ fn default_diff_algorithm ( ) -> String {
669+ "lcs" . to_string ( )
670+ }
671+
672+ #[ derive( Debug , Serialize , Deserialize ) ]
673+ pub struct ASTDiffResponse {
674+ pub line_mappings : Vec < ASTLineMapping > ,
675+ pub ast_operations : Vec < ASTOperation > ,
676+ pub summary : ASTDiffSummary ,
677+ }
678+
679+ #[ derive( Debug , Serialize , Deserialize ) ]
680+ pub struct ASTLineMapping {
681+ pub change_type : String , // "unchanged", "added", "deleted", "modified"
682+ pub source_line : Option < usize > ,
683+ pub target_line : Option < usize > ,
684+ pub source_content : Option < String > ,
685+ pub target_content : Option < String > ,
686+ pub ast_node_type : Option < String > ,
687+ pub similarity : Option < f64 > ,
688+ pub is_structural_change : bool ,
689+ pub semantic_changes : Vec < String > ,
690+ }
691+
692+ #[ derive( Debug , Serialize , Deserialize ) ]
693+ pub struct ASTOperation {
694+ pub operation_type : String , // "insert", "delete", "update", "move"
695+ pub node_type : String ,
696+ pub position : usize ,
697+ pub description : String ,
698+ pub impact_level : String , // "low", "medium", "high"
699+ }
700+
701+ #[ derive( Debug , Serialize , Deserialize ) ]
702+ pub struct ASTDiffSummary {
703+ pub total_lines : usize ,
704+ pub added_lines : usize ,
705+ pub deleted_lines : usize ,
706+ pub modified_lines : usize ,
707+ pub unchanged_lines : usize ,
708+ pub structural_changes : usize ,
709+ pub semantic_changes : usize ,
710+ }
0 commit comments