ricecoder_storage/refactoring/languages/
mod.rs1pub fn get_builtin_refactoring_configs() -> Vec<(&'static str, &'static str)> {
9 vec![
10 ("rust", include_str!("rust.yaml")),
11 ("typescript", include_str!("typescript.yaml")),
12 ("python", include_str!("python.yaml")),
13 ]
14}
15
16pub fn get_refactoring_config(language: &str) -> Option<&'static str> {
18 match language {
19 "rust" => Some(include_str!("rust.yaml")),
20 "typescript" | "ts" | "tsx" => Some(include_str!("typescript.yaml")),
21 "python" | "py" => Some(include_str!("python.yaml")),
22 _ => None,
23 }
24}
25
26#[cfg(test)]
27mod tests {
28 use super::*;
29
30 #[test]
31 fn test_get_builtin_refactoring_configs() {
32 let configs = get_builtin_refactoring_configs();
33 assert_eq!(configs.len(), 3);
34 assert!(configs.iter().any(|(lang, _)| *lang == "rust"));
35 assert!(configs.iter().any(|(lang, _)| *lang == "typescript"));
36 assert!(configs.iter().any(|(lang, _)| *lang == "python"));
37 }
38
39 #[test]
40 fn test_get_refactoring_config_rust() {
41 let config = get_refactoring_config("rust");
42 assert!(config.is_some());
43 assert!(!config.unwrap().is_empty());
44 }
45
46 #[test]
47 fn test_get_refactoring_config_typescript() {
48 let config = get_refactoring_config("typescript");
49 assert!(config.is_some());
50 assert!(!config.unwrap().is_empty());
51 }
52
53 #[test]
54 fn test_get_refactoring_config_python() {
55 let config = get_refactoring_config("python");
56 assert!(config.is_some());
57 assert!(!config.unwrap().is_empty());
58 }
59
60 #[test]
61 fn test_get_refactoring_config_aliases() {
62 assert!(get_refactoring_config("ts").is_some());
63 assert!(get_refactoring_config("tsx").is_some());
64 assert!(get_refactoring_config("py").is_some());
65 }
66
67 #[test]
68 fn test_get_refactoring_config_unknown() {
69 let config = get_refactoring_config("unknown");
70 assert!(config.is_none());
71 }
72}