MCPcopy Create free account
hub / github.com/DeusData/codebase-memory-mcp / parse_pom_xml

Function parse_pom_xml

src/pipeline/pass_pkgmap.c:553–578  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

551}
552
553static void parse_pom_xml(const char *source, int source_len, const char *rel_path,
554 cbm_pkg_entries_t *entries) {
555 const char *end = source + source_len;
556 char *group_id = pom_find_tag(source, end, "<groupId>", XML_GROUP_OPEN);
557 char *artifact_id = pom_find_tag(source, end, "<artifactId>", XML_ARTIFACT_OPEN);
558
559 if (group_id && artifact_id) {
560 /* Map: "com.myorg.myapp" → src/main/java directory */
561 char pkg_name[PKGMAP_PATH_BUF];
562 snprintf(pkg_name, sizeof(pkg_name), "%s.%s", group_id, artifact_id);
563 char *dir = path_dirname(rel_path);
564 char entry[PKGMAP_PATH_BUF];
565 snprintf(entry, sizeof(entry), "%s%ssrc/main/java", dir[0] ? dir : "", dir[0] ? "/" : "");
566 pkg_entries_push(entries, strdup(pkg_name), strdup(entry));
567
568 /* Also register just the groupId for package-level imports */
569 char grp_entry[PKGMAP_PATH_BUF];
570 snprintf(grp_entry, sizeof(grp_entry), "%s%ssrc/main/java", dir[0] ? dir : "",
571 dir[0] ? "/" : "");
572 pkg_entries_push(entries, strdup(group_id), strdup(grp_entry));
573 free(dir);
574 }
575
576 free(group_id);
577 free(artifact_id);
578}
579
580/* Gradle: build.gradle / build.gradle.kts — group = '...' */
581static void parse_build_gradle(const char *source, int source_len, const char *rel_path,

Callers 1

cbm_pkgmap_try_parseFunction · 0.85

Calls 3

pom_find_tagFunction · 0.85
path_dirnameFunction · 0.85
pkg_entries_pushFunction · 0.85

Tested by

no test coverage detected