(
file_path: String,
content: String,
language: String,
parse_budget_ms: Option<u32>,
)
| 232 | |
| 233 | #[napi] |
| 234 | pub fn extract_file( |
| 235 | file_path: String, |
| 236 | content: String, |
| 237 | language: String, |
| 238 | parse_budget_ms: Option<u32>, |
| 239 | ) -> Result<ExtractBuffers> { |
| 240 | // The whole walk runs under the stack guard (stack.rs, #1581): a file |
| 241 | // nested deeply enough to overflow this thread's stack comes back as a |
| 242 | // `defer:` error — the TS side's routine "take the wasm path" signal — |
| 243 | // instead of a SIGSEGV that kills the entire indexer process. And its |
| 244 | // parse is cancelled past `parse_budget_ms` (parse_budget.rs, #3274), a |
| 245 | // `timeout:` error, instead of a thread that spins until the process dies. |
| 246 | let out = parse_budget::with_budget(parse_budget_ms, || stack::run_guarded(|| match language.as_str() { |
| 247 | "java" => java::extract(&file_path, &content), |
| 248 | "python" => python::extract(&file_path, &content), |
| 249 | "go" => go::extract(&file_path, &content), |
| 250 | "c" | "cpp" => ccpp::extract(&file_path, &content, &language), |
| 251 | "rust" => rustlang::extract(&file_path, &content), |
| 252 | "csharp" => csharp::extract(&file_path, &content), |
| 253 | "ruby" => ruby::extract(&file_path, &content), |
| 254 | "php" => php::extract(&file_path, &content), |
| 255 | "swift" => swift::extract(&file_path, &content), |
| 256 | "kotlin" => kotlin::extract(&file_path, &content), |
| 257 | "r" => rlang::extract(&file_path, &content), |
| 258 | "lua" | "luau" => lua::extract(&file_path, &content, &language), |
| 259 | "scala" => scala::extract(&file_path, &content), |
| 260 | "dart" => dart::extract(&file_path, &content), |
| 261 | _ => tsjs::extract(&file_path, &content, &language), |
| 262 | })) |
| 263 | .map_err(Error::from_reason)?; |
| 264 | Ok(ExtractBuffers { |
| 265 | meta: out.meta.into(), |
| 266 | nodes: out.nodes.into(), |
| 267 | edges: out.edges.into(), |
| 268 | refs: out.refs.into(), |
| 269 | arena: out.arena.into(), |
| 270 | }) |
| 271 | } |
nothing calls this directly
no test coverage detected