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

Function parse_pom_xml

src/pipeline/pass_pkgmap.c:571–596  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

569}
570
571static void parse_pom_xml(const char *source, int source_len, const char *rel_path,
572 cbm_pkg_entries_t *entries) {
573 const char *end = source + source_len;
574 char *group_id = pom_find_tag(source, end, "<groupId>", XML_GROUP_OPEN);
575 char *artifact_id = pom_find_tag(source, end, "<artifactId>", XML_ARTIFACT_OPEN);
576
577 if (group_id && artifact_id) {
578 /* Map: "com.myorg.myapp" → src/main/java directory */
579 char pkg_name[PKGMAP_PATH_BUF];
580 snprintf(pkg_name, sizeof(pkg_name), "%s.%s", group_id, artifact_id);
581 char *dir = path_dirname(rel_path);
582 char entry[PKGMAP_PATH_BUF];
583 snprintf(entry, sizeof(entry), "%s%ssrc/main/java", dir[0] ? dir : "", dir[0] ? "/" : "");
584 pkg_entries_push(entries, strdup(pkg_name), strdup(entry));
585
586 /* Also register just the groupId for package-level imports */
587 char grp_entry[PKGMAP_PATH_BUF];
588 snprintf(grp_entry, sizeof(grp_entry), "%s%ssrc/main/java", dir[0] ? dir : "",
589 dir[0] ? "/" : "");
590 pkg_entries_push(entries, strdup(group_id), strdup(grp_entry));
591 free(dir);
592 }
593
594 free(group_id);
595 free(artifact_id);
596}
597
598/* Gradle: build.gradle / build.gradle.kts — group = '...' */
599static 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