Build a real extraction surface without publishing a database. The returned * JSON outlives both the extraction and collector arenas. */
| 20717 | /* Build a real extraction surface without publishing a database. The returned |
| 20718 | * JSON outlives both the extraction and collector arenas. */ |
| 20719 | static char *pipeline_namespace_surface(const char *source, bool include_defs) { |
| 20720 | CBMFileResult *fr = cbm_extract_file(source, (int)strlen(source), CBM_LANG_PYTHON, |
| 20721 | "namespace_probe", "pkg/__init__.py", 0, NULL, NULL); |
| 20722 | if (!fr || fr->has_error || fr->parse_incomplete) { |
| 20723 | cbm_free_result(fr); |
| 20724 | return NULL; |
| 20725 | } |
| 20726 | CBMArena arena; |
| 20727 | cbm_arena_init(&arena); |
| 20728 | CBMFileResult *cache[] = {fr}; |
| 20729 | cbm_file_info_t files[] = {{.rel_path = "pkg/__init__.py", .language = CBM_LANG_PYTHON}}; |
| 20730 | char *modules[] = {NULL}; |
| 20731 | int starts[2] = {0, 0}; |
| 20732 | int def_count = 0; |
| 20733 | CBMLSPDef *defs = include_defs |
| 20734 | ? cbm_pxc_collect_all_defs(NULL, &arena, cache, files, 1, |
| 20735 | "namespace_probe", modules, &def_count, starts) |
| 20736 | : NULL; |
| 20737 | cbm_lsp_surface_row_t *rows = NULL; |
| 20738 | int row_count = 0; |
| 20739 | char *json = NULL; |
| 20740 | if (cbm_lsp_surface_build_rows(NULL, "namespace_probe", cache, files, 1, defs, starts, &rows, |
| 20741 | &row_count) == 0 && |
| 20742 | row_count == 1 && rows[0].defs_json) { |
| 20743 | json = strdup(rows[0].defs_json); |
| 20744 | } |
| 20745 | cbm_store_free_lsp_surfaces(rows, row_count); |
| 20746 | free(defs); |
| 20747 | free(modules[0]); |
| 20748 | cbm_arena_destroy(&arena); |
| 20749 | cbm_free_result(fr); |
| 20750 | return json; |
| 20751 | } |
| 20752 | |
| 20753 | TEST(pipeline_python_namespace_change_admission) { |
| 20754 | const char *sources[] = { |
no test coverage detected