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

Function parse_pom_xml

src/pipeline/pass_pkgmap.c:557–582  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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