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

Function swift_find_code_token

src/pipeline/pass_pkgmap.c:766–781  ·  view source on GitHub ↗

Scans [start, end) for the next occurrence of `needle` that is not inside * a `//` line comment, a nesting-aware slash-star block comment, or a "..." * string literal (backslash-escapes honored). This is the single source of * truth for "real code" scanning below — a `.target(`, `name:`, or `path:` * spelled inside a comment or a string constant must never be mistaken for * a live declaration

Source from the content-addressed store, hash-verified

764 * spelled inside a comment or a string constant must never be mistaken for
765 * a live declaration. Returns a pointer to the match, or NULL. */
766static const char *swift_find_code_token(const char *start, const char *end, const char *needle) {
767 size_t nlen = strlen(needle);
768 int block_depth = 0;
769 bool in_str = false;
770 const char *p = start;
771 while (p < end) {
772 if (swift_skip_comment_or_string(&p, end, &block_depth, &in_str)) {
773 continue;
774 }
775 if ((size_t)(end - p) >= nlen && memcmp(p, needle, nlen) == 0) {
776 return p;
777 }
778 p++;
779 }
780 return NULL;
781}
782
783/* Find the matching ')' for the '(' at `open`, scanning forward to `end`.
784 * Delegates comment/string spans to swift_skip_comment_or_string — matching

Callers 2

swift_extract_afterFunction · 0.85
swift_scan_targetsFunction · 0.85

Calls 1

Tested by

no test coverage detected