deepwiki-rs 1.3.0

deepwiki-rs(also known as Litho) is a high-performance automatic generation engine for C4 architecture documentation, developed using Rust. It can intelligently analyze project structures, identify core components, parse dependency relationships, and leverage large language models (LLMs) to automatically generate professional architecture documentation.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
use super::{Dependency, LanguageProcessor};
use crate::types::code::{InterfaceInfo, ParameterInfo};
use regex::Regex;
use std::path::Path;

#[derive(Debug)]
pub struct CSharpProcessor {
    using_regex: Regex,
    namespace_regex: Regex,
    method_regex: Regex,
    class_regex: Regex,
    interface_regex: Regex,
    enum_regex: Regex,
    struct_regex: Regex,
    property_regex: Regex,
    constructor_regex: Regex,
}

impl CSharpProcessor {
    pub fn new() -> Self {
        Self {
            using_regex: Regex::new(r"^\s*using\s+([^;]+);").unwrap(),
            namespace_regex: Regex::new(r"^\s*namespace\s+([^;\{]+)").unwrap(),
            method_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*(static)?\s*(virtual|override|abstract|sealed)?\s*(async)?\s*(\w+)\s+(\w+)\s*\(([^)]*)\)").unwrap(),
            class_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*(static)?\s*(abstract)?\s*(sealed)?\s*(partial)?\s*class\s+(\w+)").unwrap(),
            interface_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*(partial)?\s*interface\s+(\w+)").unwrap(),
            enum_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*enum\s+(\w+)").unwrap(),
            struct_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*(readonly)?\s*(partial)?\s*struct\s+(\w+)").unwrap(),
            property_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*(static)?\s*(virtual|override|abstract)?\s*(\w+)\s+(\w+)\s*\{\s*(get|set)").unwrap(),
            constructor_regex: Regex::new(r"^\s*(public|private|protected|internal)?\s*(\w+)\s*\(([^)]*)\)").unwrap(),
        }
    }
}

impl LanguageProcessor for CSharpProcessor {
    fn supported_extensions(&self) -> Vec<&'static str> {
        vec!["cs", "csproj", "sln", "sqlproj", "sql"]
    }
    
    fn extract_dependencies(&self, content: &str, file_path: &Path) -> Vec<Dependency> {
        let mut dependencies = Vec::new();
        let source_file = file_path.to_string_lossy().to_string();
        
        // Handle .csproj files
        if file_path.extension().and_then(|e| e.to_str()) == Some("csproj") {
            return self.extract_csproj_dependencies(content, &source_file);
        }
        
        // Handle .sqlproj files
        if file_path.extension().and_then(|e| e.to_str()) == Some("sqlproj") {
            return self.extract_sqlproj_dependencies(content, &source_file);
        }
        
        // Handle .sln files
        if file_path.extension().and_then(|e| e.to_str()) == Some("sln") {
            return self.extract_sln_dependencies(content, &source_file);
        }
        
        // Handle .sql files
        if file_path.extension().and_then(|e| e.to_str()) == Some("sql") {
            return self.extract_sql_dependencies(content, &source_file);
        }
        
        // Handle .cs files
        for (line_num, line) in content.lines().enumerate() {
            // Extract using statements
            if let Some(captures) = self.using_regex.captures(line) {
                if let Some(using_path) = captures.get(1) {
                    let using_str = using_path.as_str().trim();
                    
                    // Skip using static and using alias
                    if using_str.starts_with("static ") || using_str.contains(" = ") {
                        continue;
                    }
                    
                    let is_external = using_str.starts_with("System") || 
                                    using_str.starts_with("Microsoft") ||
                                    !using_str.contains(".");
                    
                    // Parse dependency name
                    let dependency_name = self.extract_dependency_name(using_str);
                    
                    dependencies.push(Dependency {
                        name: dependency_name,
                        path: Some(source_file.clone()),
                        is_external,
                        line_number: Some(line_num + 1),
                        dependency_type: "using".to_string(),
                        version: None,
                    });
                }
            }
            
            // Extract namespace statement
            if let Some(captures) = self.namespace_regex.captures(line) {
                if let Some(namespace_name) = captures.get(1) {
                    dependencies.push(Dependency {
                        name: namespace_name.as_str().trim().to_string(),
                        path: Some(source_file.clone()),
                        is_external: false,
                        line_number: Some(line_num + 1),
                        dependency_type: "namespace".to_string(),
                        version: None,
                    });
                }
            }
        }
        
        dependencies
    }
    
    fn determine_component_type(&self, file_path: &Path, content: &str) -> String {
        let file_name = file_path.file_name()
            .and_then(|n| n.to_str())
            .unwrap_or("");
        
        // Check for project files
        if file_name.ends_with(".csproj") {
            // Determine project type from SDK or OutputType
            if content.contains("Microsoft.NET.Sdk.Web") {
                return "csharp_web_project".to_string();
            } else if content.contains("<OutputType>Exe</OutputType>") {
                return "csharp_console_project".to_string();
            } else if content.contains("<OutputType>Library</OutputType>") || content.contains("Microsoft.NET.Sdk") {
                return "csharp_library_project".to_string();
            } else if content.contains("Microsoft.NET.Test.Sdk") || file_name.contains("Test") {
                return "csharp_test_project".to_string();
            }
            return "csharp_project".to_string();
        }
        
        // Check for SQL project files
        if file_name.ends_with(".sqlproj") {
            return "sql_database_project".to_string();
        }
        
        // Check for solution files
        if file_name.ends_with(".sln") {
            return "csharp_solution".to_string();
        }
        
        // Check for SQL files
        if file_name.ends_with(".sql") {
            if content.to_uppercase().contains("CREATE TABLE") || content.to_uppercase().contains("ALTER TABLE") {
                return "sql_table_definition".to_string();
            } else if content.to_uppercase().contains("CREATE PROCEDURE") || content.to_uppercase().contains("ALTER PROCEDURE") {
                return "sql_stored_procedure".to_string();
            } else if content.to_uppercase().contains("CREATE VIEW") || content.to_uppercase().contains("ALTER VIEW") {
                return "sql_view".to_string();
            } else if content.to_uppercase().contains("CREATE FUNCTION") || content.to_uppercase().contains("ALTER FUNCTION") {
                return "sql_function".to_string();
            } else if content.to_uppercase().contains("CREATE TRIGGER") {
                return "sql_trigger".to_string();
            }
            return "sql_script".to_string();
        }
        
        // Check for test files
        if file_name.ends_with("Test.cs") || file_name.ends_with("Tests.cs") ||
           content.contains("[Test]") || content.contains("[TestMethod]") {
            return "csharp_test".to_string();
        }
        
        // Check for common patterns
        if content.contains("interface ") {
            "csharp_interface".to_string()
        } else if content.contains("enum ") {
            "csharp_enum".to_string()
        } else if content.contains("struct ") {
            "csharp_struct".to_string()
        } else if content.contains("abstract class") {
            "csharp_abstract_class".to_string()
        } else if content.contains("static class") {
            "csharp_static_class".to_string()
        } else if content.contains("sealed class") {
            "csharp_sealed_class".to_string()
        } else if content.contains("partial class") {
            "csharp_partial_class".to_string()
        } else if content.contains("class ") {
            "csharp_class".to_string()
        } else {
            "csharp_file".to_string()
        }
    }
    
    fn is_important_line(&self, line: &str) -> bool {
        let trimmed = line.trim();
        
        // Type declarations
        if trimmed.starts_with("public class ") || trimmed.starts_with("class ") ||
           trimmed.starts_with("interface ") || trimmed.starts_with("enum ") ||
           trimmed.starts_with("struct ") || trimmed.starts_with("public ") || 
           trimmed.starts_with("private ") || trimmed.starts_with("protected ") ||
           trimmed.starts_with("internal ") || trimmed.starts_with("using ") ||
           trimmed.starts_with("namespace ") {
            return true;
        }
        
        // Attributes
        if trimmed.starts_with('[') && trimmed.contains(']') {
            return true;
        }
        
        // Important comments
        if trimmed.contains("TODO") || trimmed.contains("FIXME") || 
           trimmed.contains("NOTE") || trimmed.contains("HACK") {
            return true;
        }
        
        false
    }
    
    fn language_name(&self) -> &'static str {
        "C#"
    }

    fn extract_interfaces(&self, content: &str, file_path: &Path) -> Vec<InterfaceInfo> {
        let mut interfaces = Vec::new();
        
        // Check if this is a SQL file
        let file_name = file_path.file_name()
            .and_then(|n| n.to_str())
            .unwrap_or("");
        
        if file_name.ends_with(".sql") {
            return self.extract_sql_interfaces(content);
        }
        
        if file_name.ends_with(".sqlproj") {
            return self.extract_sqlproj_interfaces(content);
        }
        
        let lines: Vec<&str> = content.lines().collect();
        
        for (i, line) in lines.iter().enumerate() {
            // Extract class definitions
            if let Some(captures) = self.class_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let is_static = captures.get(2).is_some();
                let is_abstract = captures.get(3).is_some();
                let is_sealed = captures.get(4).is_some();
                let is_partial = captures.get(5).is_some();
                let name = captures.get(6).map(|m| m.as_str()).unwrap_or("").to_string();
                
                let mut interface_type = "class".to_string();
                if is_static {
                    interface_type = "static_class".to_string();
                } else if is_abstract {
                    interface_type = "abstract_class".to_string();
                } else if is_sealed {
                    interface_type = "sealed_class".to_string();
                } else if is_partial {
                    interface_type = "partial_class".to_string();
                }
                
                interfaces.push(InterfaceInfo {
                    name,
                    interface_type,
                    visibility: visibility.to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_xml_doc(&lines, i),
                });
            }
            
            // Extract interface definitions
            if let Some(captures) = self.interface_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let is_partial = captures.get(2).is_some();
                let name = captures.get(3).map(|m| m.as_str()).unwrap_or("").to_string();
                
                let interface_type = if is_partial {
                    "partial_interface".to_string()
                } else {
                    "interface".to_string()
                };
                
                interfaces.push(InterfaceInfo {
                    name,
                    interface_type,
                    visibility: visibility.to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_xml_doc(&lines, i),
                });
            }
            
            // Extract struct definitions
            if let Some(captures) = self.struct_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let is_readonly = captures.get(2).is_some();
                let is_partial = captures.get(3).is_some();
                let name = captures.get(4).map(|m| m.as_str()).unwrap_or("").to_string();
                
                let mut interface_type = "struct".to_string();
                if is_readonly {
                    interface_type = "readonly_struct".to_string();
                } else if is_partial {
                    interface_type = "partial_struct".to_string();
                }
                
                interfaces.push(InterfaceInfo {
                    name,
                    interface_type,
                    visibility: visibility.to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_xml_doc(&lines, i),
                });
            }
            
            // Extract enum definitions
            if let Some(captures) = self.enum_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                interfaces.push(InterfaceInfo {
                    name,
                    interface_type: "enum".to_string(),
                    visibility: visibility.to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_xml_doc(&lines, i),
                });
            }
            
            // Extract property definitions
            if let Some(captures) = self.property_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let is_static = captures.get(2).is_some();
                let modifier = captures.get(3).map(|m| m.as_str()).unwrap_or("");
                let return_type = captures.get(4).map(|m| m.as_str()).unwrap_or("").to_string();
                let name = captures.get(5).map(|m| m.as_str()).unwrap_or("").to_string();
                
                let mut interface_type = "property".to_string();
                if is_static {
                    interface_type = "static_property".to_string();
                } else if modifier == "virtual" {
                    interface_type = "virtual_property".to_string();
                } else if modifier == "override" {
                    interface_type = "override_property".to_string();
                } else if modifier == "abstract" {
                    interface_type = "abstract_property".to_string();
                }
                
                interfaces.push(InterfaceInfo {
                    name,
                    interface_type,
                    visibility: visibility.to_string(),
                    parameters: Vec::new(),
                    return_type: Some(return_type),
                    description: self.extract_xml_doc(&lines, i),
                });
            }
            
            // Extract method definitions
            if let Some(captures) = self.method_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let is_static = captures.get(2).is_some();
                let modifier = captures.get(3).map(|m| m.as_str()).unwrap_or("");
                let is_async = captures.get(4).is_some();
                let return_type = captures.get(5).map(|m| m.as_str()).unwrap_or("").to_string();
                let name = captures.get(6).map(|m| m.as_str()).unwrap_or("").to_string();
                let params_str = captures.get(7).map(|m| m.as_str()).unwrap_or("");
                
                // Skip C# keywords
                if return_type == "if" || return_type == "for" || return_type == "while" || 
                   return_type == "foreach" || return_type == "switch" || return_type == "try" ||
                   return_type == "using" || return_type == "lock" {
                    continue;
                }
                
                let parameters = self.parse_csharp_parameters(params_str);
                let mut interface_type = "method".to_string();
                if is_static {
                    interface_type = "static_method".to_string();
                } else if is_async {
                    interface_type = "async_method".to_string();
                } else if modifier == "virtual" {
                    interface_type = "virtual_method".to_string();
                } else if modifier == "override" {
                    interface_type = "override_method".to_string();
                } else if modifier == "abstract" {
                    interface_type = "abstract_method".to_string();
                } else if modifier == "sealed" {
                    interface_type = "sealed_method".to_string();
                }
                
                interfaces.push(InterfaceInfo {
                    name,
                    interface_type,
                    visibility: visibility.to_string(),
                    parameters,
                    return_type: Some(return_type),
                    description: self.extract_xml_doc(&lines, i),
                });
            }
            
            // Extract constructors
            if let Some(captures) = self.constructor_regex.captures(line) {
                let visibility = captures.get(1).map(|m| m.as_str()).unwrap_or("private");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                let params_str = captures.get(3).map(|m| m.as_str()).unwrap_or("");
                
                // Simple check if it's a constructor (name starts with uppercase)
                if name.chars().next().map_or(false, |c| c.is_uppercase()) {
                    let parameters = self.parse_csharp_parameters(params_str);
                    
                    interfaces.push(InterfaceInfo {
                        name,
                        interface_type: "constructor".to_string(),
                        visibility: visibility.to_string(),
                        parameters,
                        return_type: None,
                        description: self.extract_xml_doc(&lines, i),
                    });
                }
            }
        }
        
        interfaces
    }
}

impl CSharpProcessor {
    /// Extract dependencies from .csproj files (NuGet packages and project references)
    fn extract_csproj_dependencies(&self, content: &str, source_file: &str) -> Vec<Dependency> {
        let mut dependencies = Vec::new();
        
        for (line_num, line) in content.lines().enumerate() {
            let trimmed = line.trim();
            
            // Extract NuGet package references: <PackageReference Include="Package.Name" Version="1.0.0" />
            if trimmed.starts_with("<PackageReference") && trimmed.contains("Include=") {
                if let Some(start) = trimmed.find("Include=\"") {
                    let after_include = &trimmed[start + 9..];
                    if let Some(end) = after_include.find('"') {
                        let package_name = &after_include[..end];
                        
                        // Extract version if present
                        let version = if let Some(ver_start) = trimmed.find("Version=\"") {
                            let after_version = &trimmed[ver_start + 9..];
                            after_version.find('"').map(|ver_end| after_version[..ver_end].to_string())
                        } else {
                            None
                        };
                        
                        dependencies.push(Dependency {
                            name: package_name.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: true,
                            line_number: Some(line_num + 1),
                            dependency_type: "nuget_package".to_string(),
                            version,
                        });
                    }
                }
            }
            
            // Extract project references: <ProjectReference Include="..\Other.Project\Other.Project.csproj" />
            if trimmed.starts_with("<ProjectReference") && trimmed.contains("Include=") {
                if let Some(start) = trimmed.find("Include=\"") {
                    let after_include = &trimmed[start + 9..];
                    if let Some(end) = after_include.find('"') {
                        let project_path = &after_include[..end];
                        
                        // Extract project name from path
                        let project_name = project_path
                            .split(['/', '\\'])
                            .last()
                            .unwrap_or(project_path)
                            .trim_end_matches(".csproj")
                            .to_string();
                        
                        dependencies.push(Dependency {
                            name: project_name,
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "project_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract framework references: <FrameworkReference Include="Microsoft.AspNetCore.App" />
            if trimmed.starts_with("<FrameworkReference") && trimmed.contains("Include=") {
                if let Some(start) = trimmed.find("Include=\"") {
                    let after_include = &trimmed[start + 9..];
                    if let Some(end) = after_include.find('"') {
                        let framework_name = &after_include[..end];
                        
                        dependencies.push(Dependency {
                            name: framework_name.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: true,
                            line_number: Some(line_num + 1),
                            dependency_type: "framework_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
        }
        
        dependencies
    }
    
    /// Extract project references from .sln files
    fn extract_sln_dependencies(&self, content: &str, source_file: &str) -> Vec<Dependency> {
        let mut dependencies = Vec::new();
        
        for (line_num, line) in content.lines().enumerate() {
            let trimmed = line.trim();
            
            // Extract project entries: Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ProjectName", "Path\ProjectName.csproj", "{GUID}"
            if trimmed.starts_with("Project(") && trimmed.contains(".csproj") {
                // Extract project name (between first pair of quotes after =)
                if let Some(name_start) = trimmed.find("= \"") {
                    let after_equals = &trimmed[name_start + 3..];
                    if let Some(name_end) = after_equals.find('"') {
                        let project_name = &after_equals[..name_end];
                        
                        dependencies.push(Dependency {
                            name: project_name.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "solution_project".to_string(),
                            version: None,
                        });
                    }
                }
            }
        }
        
        dependencies
    }

    /// Parse C# method parameters
    fn parse_csharp_parameters(&self, params_str: &str) -> Vec<ParameterInfo> {
        let mut parameters = Vec::new();
        
        if params_str.trim().is_empty() {
            return parameters;
        }
        
        // Simple parameter parsing, handling basic cases
        for param in params_str.split(',') {
            let param = param.trim();
            if param.is_empty() {
                continue;
            }
            
            // Parse parameter format: Type name, ref Type name, out Type name, params Type[] name, Type name = default
            let parts: Vec<&str> = param.split_whitespace().collect();
            if parts.len() >= 2 {
                let (param_type, name, is_optional) = if parts[0] == "ref" || parts[0] == "out" || parts[0] == "in" || parts[0] == "params" {
                    if parts.len() >= 3 {
                        (parts[1].to_string(), parts[2].to_string(), false)
                    } else {
                        continue;
                    }
                } else {
                    // Check for default value (optional parameter)
                    let has_default = param.contains('=');
                    let name = parts[1].split('=').next().unwrap_or(parts[1]).to_string();
                    (parts[0].to_string(), name, has_default)
                };
                
                // Handle generic types and nullable types
                let clean_type = if param_type.contains('<') || param_type.contains('?') {
                    param_type
                } else {
                    param_type
                };
                
                parameters.push(ParameterInfo {
                    name,
                    param_type: clean_type,
                    is_optional,
                    description: None,
                });
            }
        }
        
        parameters
    }
    
    /// Extract XML documentation comments
    fn extract_xml_doc(&self, lines: &[&str], current_line: usize) -> Option<String> {
        let mut doc_lines = Vec::new();
        
        // Search upward for XML doc comments
        for i in (0..current_line).rev() {
            let line = lines[i].trim();
            
            if line.starts_with("///") {
                let content = line.trim_start_matches("///").trim();
                // Extract content from <summary> tags
                if content.starts_with("<summary>") {
                    let text = content.trim_start_matches("<summary>").trim_end_matches("</summary>").trim();
                    if !text.is_empty() {
                        doc_lines.insert(0, text.to_string());
                    }
                } else if content.ends_with("</summary>") {
                    let text = content.trim_end_matches("</summary>").trim();
                    if !text.is_empty() {
                        doc_lines.insert(0, text.to_string());
                    }
                } else if !content.is_empty() && !content.starts_with('<') && !content.ends_with('>') {
                    doc_lines.insert(0, content.to_string());
                }
            } else if !line.is_empty() && !line.starts_with('[') {
                break;
            }
        }
        
        if doc_lines.is_empty() {
            None
        } else {
            Some(doc_lines.join(" "))
        }
    }

    /// Extract dependency name from C# using path
    fn extract_dependency_name(&self, using_path: &str) -> String {
        // For System.Collections.Generic, return Generic
        if let Some(namespace_name) = using_path.split('.').last() {
            namespace_name.to_string()
        } else {
            using_path.to_string()
        }
    }
    
    /// Extract interfaces from SQL files (tables, views, stored procedures, functions, triggers)
    fn extract_sql_interfaces(&self, content: &str) -> Vec<InterfaceInfo> {
        let mut interfaces = Vec::new();
        let lines: Vec<&str> = content.lines().collect();
        
        // Regex patterns for SQL objects
        let create_table_re = regex::Regex::new(r"(?i)CREATE\s+TABLE\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let alter_table_re = regex::Regex::new(r"(?i)ALTER\s+TABLE\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let create_view_re = regex::Regex::new(r"(?i)CREATE\s+(?:OR\s+ALTER\s+)?VIEW\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let create_proc_re = regex::Regex::new(r"(?i)CREATE\s+(?:OR\s+ALTER\s+)?PROC(?:EDURE)?\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let create_func_re = regex::Regex::new(r"(?i)CREATE\s+(?:OR\s+ALTER\s+)?FUNCTION\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let create_trigger_re = regex::Regex::new(r"(?i)CREATE\s+(?:OR\s+ALTER\s+)?TRIGGER\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let create_index_re = regex::Regex::new(r"(?i)CREATE\s+(?:UNIQUE\s+)?(?:CLUSTERED\s+|NONCLUSTERED\s+)?INDEX\s+\[?(\w+)\]?\s+ON\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        let create_type_re = regex::Regex::new(r"(?i)CREATE\s+TYPE\s+(?:\[?(\w+)\]?\.)?\[?(\w+)\]?").unwrap();
        
        for (i, line) in lines.iter().enumerate() {
            let line_content = *line;
            
            // Extract table definitions
            if let Some(captures) = create_table_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                // Extract columns from CREATE TABLE
                let columns = self.extract_sql_columns(&lines, i);
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_table".to_string(),
                    visibility: "public".to_string(),
                    parameters: columns,
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract ALTER TABLE (for modifications)
            if let Some(captures) = alter_table_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_table_alter".to_string(),
                    visibility: "public".to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract view definitions
            if let Some(captures) = create_view_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_view".to_string(),
                    visibility: "public".to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract stored procedure definitions
            if let Some(captures) = create_proc_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                // Extract parameters
                let params = self.extract_sql_proc_parameters(&lines, i);
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_stored_procedure".to_string(),
                    visibility: "public".to_string(),
                    parameters: params,
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract function definitions
            if let Some(captures) = create_func_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                // Extract parameters
                let params = self.extract_sql_proc_parameters(&lines, i);
                
                // Try to extract return type
                let return_type = self.extract_sql_function_return_type(&lines, i);
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_function".to_string(),
                    visibility: "public".to_string(),
                    parameters: params,
                    return_type,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract trigger definitions
            if let Some(captures) = create_trigger_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_trigger".to_string(),
                    visibility: "public".to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract index definitions
            if let Some(captures) = create_index_re.captures(line_content) {
                let index_name = captures.get(1).map(|m| m.as_str()).unwrap_or("").to_string();
                let schema = captures.get(2).map(|m| m.as_str()).unwrap_or("dbo");
                let table_name = captures.get(3).map(|m| m.as_str()).unwrap_or("");
                
                interfaces.push(InterfaceInfo {
                    name: format!("{} ON {}.{}", index_name, schema, table_name),
                    interface_type: "sql_index".to_string(),
                    visibility: "public".to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
            
            // Extract user-defined types
            if let Some(captures) = create_type_re.captures(line_content) {
                let schema = captures.get(1).map(|m| m.as_str()).unwrap_or("dbo");
                let name = captures.get(2).map(|m| m.as_str()).unwrap_or("").to_string();
                
                interfaces.push(InterfaceInfo {
                    name: format!("{}.{}", schema, name),
                    interface_type: "sql_type".to_string(),
                    visibility: "public".to_string(),
                    parameters: Vec::new(),
                    return_type: None,
                    description: self.extract_sql_comment(&lines, i),
                });
            }
        }
        
        interfaces
    }
    
    /// Extract interfaces from .sqlproj files
    fn extract_sqlproj_interfaces(&self, content: &str) -> Vec<InterfaceInfo> {
        let mut interfaces = Vec::new();
        
        // Extract project name from PropertyGroup
        let project_name_re = regex::Regex::new(r"<Name>([^<]+)</Name>").unwrap();
        if let Some(captures) = project_name_re.captures(content) {
            let name = captures.get(1).map(|m| m.as_str()).unwrap_or("").to_string();
            interfaces.push(InterfaceInfo {
                name,
                interface_type: "sql_database_project".to_string(),
                visibility: "public".to_string(),
                parameters: Vec::new(),
                return_type: None,
                description: Some("SQL Server Database Project".to_string()),
            });
        }
        
        // Count SQL objects by type
        let mut tables = 0;
        let mut views = 0;
        let mut procs = 0;
        let mut functions = 0;
        
        for line in content.lines() {
            let trimmed = line.trim();
            if trimmed.contains("<Build Include=") {
                let lower = trimmed.to_lowercase();
                if lower.contains("tables") || lower.contains(".table.") {
                    tables += 1;
                } else if lower.contains("views") || lower.contains(".view.") {
                    views += 1;
                } else if lower.contains("procedures") || lower.contains("storedprocedures") || lower.contains(".proc.") {
                    procs += 1;
                } else if lower.contains("functions") || lower.contains(".function.") {
                    functions += 1;
                }
            }
        }
        
        // Add summary interface
        if tables > 0 || views > 0 || procs > 0 || functions > 0 {
            interfaces.push(InterfaceInfo {
                name: "DatabaseObjects".to_string(),
                interface_type: "sql_project_summary".to_string(),
                visibility: "public".to_string(),
                parameters: vec![
                    ParameterInfo { name: "Tables".to_string(), param_type: format!("{}", tables), is_optional: false, description: None },
                    ParameterInfo { name: "Views".to_string(), param_type: format!("{}", views), is_optional: false, description: None },
                    ParameterInfo { name: "StoredProcedures".to_string(), param_type: format!("{}", procs), is_optional: false, description: None },
                    ParameterInfo { name: "Functions".to_string(), param_type: format!("{}", functions), is_optional: false, description: None },
                ],
                return_type: None,
                description: Some("Summary of database objects in project".to_string()),
            });
        }
        
        interfaces
    }
    
    /// Extract column definitions from CREATE TABLE
    fn extract_sql_columns(&self, lines: &[&str], start_line: usize) -> Vec<ParameterInfo> {
        let mut columns = Vec::new();
        let column_re = regex::Regex::new(r"(?i)^\s*\[?(\w+)\]?\s+([\w\(\),\s]+?)(?:\s+(?:NOT\s+)?NULL|\s+PRIMARY\s+KEY|\s+IDENTITY|\s+DEFAULT|\s*,|\s*\))").unwrap();
        
        // Look for columns in the following lines until we hit a closing paren or GO
        for i in (start_line + 1)..lines.len().min(start_line + 50) {
            let line = lines[i].trim();
            
            if line.starts_with(')') || line.to_uppercase().starts_with("GO") || line.to_uppercase().starts_with("CREATE") {
                break;
            }
            
            // Skip constraint definitions
            if line.to_uppercase().starts_with("CONSTRAINT") || 
               line.to_uppercase().starts_with("PRIMARY KEY") ||
               line.to_uppercase().starts_with("FOREIGN KEY") ||
               line.to_uppercase().starts_with("UNIQUE") ||
               line.to_uppercase().starts_with("CHECK") {
                continue;
            }
            
            if let Some(captures) = column_re.captures(line) {
                let name = captures.get(1).map(|m| m.as_str()).unwrap_or("").to_string();
                let data_type = captures.get(2).map(|m| m.as_str().trim()).unwrap_or("").to_string();
                
                if !name.is_empty() && !data_type.is_empty() {
                    columns.push(ParameterInfo {
                        name,
                        param_type: data_type,
                        is_optional: false,
                        description: None,
                    });
                }
            }
        }
        
        columns
    }
    
    /// Extract parameters from stored procedure or function
    fn extract_sql_proc_parameters(&self, lines: &[&str], start_line: usize) -> Vec<ParameterInfo> {
        let mut params = Vec::new();
        let param_re = regex::Regex::new(r"(?i)@(\w+)\s+([\w\(\),\s]+?)(?:\s*=\s*([^,\n]+))?(?:\s*,|\s*\)|\s*$|\s+AS|\s+WITH)").unwrap();
        
        // Collect lines until AS keyword
        let mut param_section = String::new();
        for i in start_line..lines.len().min(start_line + 30) {
            let line = lines[i];
            param_section.push_str(line);
            param_section.push(' ');
            
            if line.to_uppercase().contains(" AS ") || line.to_uppercase().trim() == "AS" {
                break;
            }
        }
        
        for captures in param_re.captures_iter(&param_section) {
            let name = captures.get(1).map(|m| m.as_str()).unwrap_or("").to_string();
            let data_type = captures.get(2).map(|m| m.as_str().trim()).unwrap_or("").to_string();
            let default = captures.get(3).map(|m| m.as_str().trim().to_string());
            
            if !name.is_empty() {
                params.push(ParameterInfo {
                    name: format!("@{}", name),
                    param_type: data_type,
                    is_optional: default.is_some(),
                    description: default,
                });
            }
        }
        
        params
    }
    
    /// Extract return type from SQL function
    fn extract_sql_function_return_type(&self, lines: &[&str], start_line: usize) -> Option<String> {
        let returns_re = regex::Regex::new(r"(?i)RETURNS\s+([\w\(\),\s]+?)(?:\s+AS|\s+WITH|\s+BEGIN)").unwrap();
        
        // Look for RETURNS keyword
        for i in start_line..lines.len().min(start_line + 20) {
            let line = lines[i];
            if let Some(captures) = returns_re.captures(line) {
                return captures.get(1).map(|m| m.as_str().trim().to_string());
            }
        }
        
        None
    }
    
    /// Extract SQL comment (-- or /* */) preceding a statement
    fn extract_sql_comment(&self, lines: &[&str], line_index: usize) -> Option<String> {
        let mut comments = Vec::new();
        
        // Look backwards for comments
        for i in (0..line_index).rev() {
            let line = lines[i].trim();
            
            if line.starts_with("--") {
                comments.insert(0, line[2..].trim().to_string());
            } else if line.ends_with("*/") {
                // Multi-line comment - find the start
                let mut comment_text = String::new();
                for j in (0..=i).rev() {
                    let comment_line = lines[j].trim();
                    if comment_line.starts_with("/*") {
                        comment_text = comment_line[2..].trim_end_matches("*/").trim().to_string();
                        break;
                    } else if comment_line.ends_with("*/") {
                        comment_text = comment_line.trim_end_matches("*/").trim().to_string();
                    } else {
                        comment_text = format!("{} {}", comment_line, comment_text);
                    }
                }
                if !comment_text.is_empty() {
                    return Some(comment_text.trim().to_string());
                }
                break;
            } else if line.is_empty() || line.to_uppercase().starts_with("GO") {
                continue;
            } else {
                break;
            }
        }
        
        if comments.is_empty() {
            None
        } else {
            Some(comments.join(" "))
        }
    }
    
    /// Extract dependencies from .sqlproj files (SQL project references and build items)
    fn extract_sqlproj_dependencies(&self, content: &str, source_file: &str) -> Vec<Dependency> {
        let mut dependencies = Vec::new();
        
        for (line_num, line) in content.lines().enumerate() {
            let trimmed = line.trim();
            
            // Extract SQL file references: <Build Include="dbo\Tables\Users.sql" />
            if (trimmed.starts_with("<Build") || trimmed.starts_with("<PreDeploy") || 
                trimmed.starts_with("<PostDeploy")) && trimmed.contains("Include=") {
                if let Some(start) = trimmed.find("Include=\"") {
                    let after_include = &trimmed[start + 9..];
                    if let Some(end) = after_include.find('"') {
                        let file_path = &after_include[..end];
                        
                        // Extract SQL object name and type from path
                        let parts: Vec<&str> = file_path.split(['/', '\\', '.']).collect();
                        let object_type = if parts.len() > 2 {
                            parts[parts.len() - 3].to_string() // e.g., "Tables", "StoredProcedures"
                        } else {
                            "sql_object".to_string()
                        };
                        
                        let object_name = parts
                            .iter()
                            .rev()
                            .nth(1)
                            .unwrap_or(&"unknown")
                            .to_string();
                        
                        dependencies.push(Dependency {
                            name: object_name,
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: object_type,
                            version: None,
                        });
                    }
                }
            }
            
            // Extract project references: <ProjectReference Include="..\OtherDatabase\OtherDatabase.sqlproj" />
            if trimmed.starts_with("<ProjectReference") && trimmed.contains("Include=") {
                if let Some(start) = trimmed.find("Include=\"") {
                    let after_include = &trimmed[start + 9..];
                    if let Some(end) = after_include.find('"') {
                        let project_path = &after_include[..end];
                        
                        // Extract project name from path
                        let project_name = project_path
                            .split(['/', '\\'])
                            .last()
                            .unwrap_or(project_path)
                            .trim_end_matches(".sqlproj")
                            .to_string();
                        
                        dependencies.push(Dependency {
                            name: project_name,
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "database_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract DACPAC references: <ArtifactReference Include="..\..\Packages\DatabaseName.dacpac" />
            if trimmed.starts_with("<ArtifactReference") && trimmed.contains("Include=") {
                if let Some(start) = trimmed.find("Include=\"") {
                    let after_include = &trimmed[start + 9..];
                    if let Some(end) = after_include.find('"') {
                        let dacpac_path = &after_include[..end];
                        
                        let dacpac_name = dacpac_path
                            .split(['/', '\\'])
                            .last()
                            .unwrap_or(dacpac_path)
                            .trim_end_matches(".dacpac")
                            .to_string();
                        
                        dependencies.push(Dependency {
                            name: dacpac_name,
                            path: Some(source_file.to_string()),
                            is_external: true,
                            line_number: Some(line_num + 1),
                            dependency_type: "dacpac_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
        }
        
        dependencies
    }
    
    /// Extract dependencies from .sql files (table references, stored procedure calls, etc.)
    fn extract_sql_dependencies(&self, content: &str, source_file: &str) -> Vec<Dependency> {
        let mut dependencies = Vec::new();
        
        for (line_num, line) in content.lines().enumerate() {
            let upper_line = line.to_uppercase();
            let trimmed = line.trim();
            
            // Skip comments
            if trimmed.starts_with("--") || trimmed.starts_with("/*") {
                continue;
            }
            
            // Extract table references from FROM clause
            if upper_line.contains(" FROM ") {
                if let Some(from_pos) = upper_line.find(" FROM ") {
                    let after_from = &line[from_pos + 6..];
                    let table_part = after_from
                        .split_whitespace()
                        .next()
                        .unwrap_or("")
                        .trim_matches(|c: char| !c.is_alphanumeric() && c != '.' && c != '_' && c != '[' && c != ']');
                    
                    if !table_part.is_empty() {
                        dependencies.push(Dependency {
                            name: table_part.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "table_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract table references from JOIN clause
            if upper_line.contains(" JOIN ") {
                if let Some(join_pos) = upper_line.find(" JOIN ") {
                    let after_join = &line[join_pos + 6..];
                    let table_part = after_join
                        .split_whitespace()
                        .next()
                        .unwrap_or("")
                        .trim_matches(|c: char| !c.is_alphanumeric() && c != '.' && c != '_' && c != '[' && c != ']');
                    
                    if !table_part.is_empty() {
                        dependencies.push(Dependency {
                            name: table_part.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "table_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract table references from INSERT INTO
            if upper_line.contains("INSERT INTO ") {
                if let Some(insert_pos) = upper_line.find("INSERT INTO ") {
                    let after_insert = &line[insert_pos + 12..];
                    let table_part = after_insert
                        .split_whitespace()
                        .next()
                        .unwrap_or("")
                        .trim_matches(|c: char| !c.is_alphanumeric() && c != '.' && c != '_' && c != '[' && c != ']');
                    
                    if !table_part.is_empty() {
                        dependencies.push(Dependency {
                            name: table_part.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "table_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract table references from UPDATE
            if upper_line.contains("UPDATE ") && !upper_line.contains("UPDATE STATISTICS") {
                if let Some(update_pos) = upper_line.find("UPDATE ") {
                    let after_update = &line[update_pos + 7..];
                    let table_part = after_update
                        .split_whitespace()
                        .next()
                        .unwrap_or("")
                        .trim_matches(|c: char| !c.is_alphanumeric() && c != '.' && c != '_' && c != '[' && c != ']');
                    
                    if !table_part.is_empty() {
                        dependencies.push(Dependency {
                            name: table_part.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "table_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract table references from DELETE FROM
            if upper_line.contains("DELETE FROM ") {
                if let Some(delete_pos) = upper_line.find("DELETE FROM ") {
                    let after_delete = &line[delete_pos + 12..];
                    let table_part = after_delete
                        .split_whitespace()
                        .next()
                        .unwrap_or("")
                        .trim_matches(|c: char| !c.is_alphanumeric() && c != '.' && c != '_' && c != '[' && c != ']');
                    
                    if !table_part.is_empty() {
                        dependencies.push(Dependency {
                            name: table_part.to_string(),
                            path: Some(source_file.to_string()),
                            is_external: false,
                            line_number: Some(line_num + 1),
                            dependency_type: "table_reference".to_string(),
                            version: None,
                        });
                    }
                }
            }
            
            // Extract stored procedure calls: EXEC/EXECUTE ProcedureName
            if upper_line.contains("EXEC ") || upper_line.contains("EXECUTE ") {
                let exec_pos = if let Some(pos) = upper_line.find("EXECUTE ") {
                    pos + 8
                } else if let Some(pos) = upper_line.find("EXEC ") {
                    pos + 5
                } else {
                    continue;
                };
                
                let after_exec = &line[exec_pos..];
                let proc_name = after_exec
                    .split_whitespace()
                    .next()
                    .unwrap_or("")
                    .trim_matches(|c: char| !c.is_alphanumeric() && c != '.' && c != '_' && c != '[' && c != ']');
                
                if !proc_name.is_empty() && !proc_name.starts_with('@') {
                    dependencies.push(Dependency {
                        name: proc_name.to_string(),
                        path: Some(source_file.to_string()),
                        is_external: false,
                        line_number: Some(line_num + 1),
                        dependency_type: "stored_procedure_call".to_string(),
                        version: None,
                    });
                }
            }
        }
        
        dependencies
    }
}