| 322 | } |
| 323 | |
| 324 | static void parse_python_imports(CBMExtractCtx *ctx) { |
| 325 | TSTreeCursor cursor = ts_tree_cursor_new(ctx->root); |
| 326 | if (!ts_tree_cursor_goto_first_child(&cursor)) { |
| 327 | ts_tree_cursor_delete(&cursor); |
| 328 | return; |
| 329 | } |
| 330 | do { |
| 331 | TSNode node = ts_tree_cursor_current_node(&cursor); |
| 332 | const char *kind = ts_node_type(node); |
| 333 | |
| 334 | if (strcmp(kind, "import_statement") == 0) { |
| 335 | process_py_import_stmt(ctx, node); |
| 336 | } else if (strcmp(kind, "import_from_statement") == 0 || |
| 337 | strcmp(kind, "future_import_statement") == 0) { |
| 338 | // `from __future__ import annotations` is a distinct node type in |
| 339 | // tree-sitter-python but has the same shape (module + name list). |
| 340 | process_py_import_from(ctx, node); |
| 341 | } |
| 342 | } while (ts_tree_cursor_goto_next_sibling(&cursor)); |
| 343 | ts_tree_cursor_delete(&cursor); |
| 344 | } |
| 345 | |
| 346 | /* Ordered Python namespace facts are a separate content-only pass. The older |
| 347 | * import records keep their existing graph/heuristic meaning. */ |
no test coverage detected