| 216 | |
| 217 | #[napi] |
| 218 | pub fn extract_file(file_path: String, content: String, language: String) -> Result<ExtractBuffers> { |
| 219 | let out = match language.as_str() { |
| 220 | "java" => java::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 221 | "python" => python::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 222 | "go" => go::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 223 | "c" | "cpp" => ccpp::extract(&file_path, &content, &language).map_err(Error::from_reason)?, |
| 224 | "rust" => rustlang::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 225 | "csharp" => csharp::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 226 | "ruby" => ruby::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 227 | "php" => php::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 228 | "swift" => swift::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 229 | "kotlin" => kotlin::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 230 | "r" => rlang::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 231 | "lua" | "luau" => lua::extract(&file_path, &content, &language).map_err(Error::from_reason)?, |
| 232 | "scala" => scala::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 233 | "dart" => dart::extract(&file_path, &content).map_err(Error::from_reason)?, |
| 234 | _ => tsjs::extract(&file_path, &content, &language).map_err(Error::from_reason)?, |
| 235 | }; |
| 236 | Ok(ExtractBuffers { |
| 237 | meta: out.meta.into(), |
| 238 | nodes: out.nodes.into(), |
| 239 | edges: out.edges.into(), |
| 240 | refs: out.refs.into(), |
| 241 | arena: out.arena.into(), |
| 242 | }) |
| 243 | } |