Skip to content

fix(#682): callers stops counting trailing-comment mentions as call sites - #683

Merged
justrach merged 2 commits into
release/0.2.5833-mcp2026from
fix/issue-682-trailing-comment-callers
Aug 5, 2026
Merged

fix(#682): callers stops counting trailing-comment mentions as call sites#683
justrach merged 2 commits into
release/0.2.5833-mcp2026from
fix/issue-682-trailing-comment-callers

Conversation

@justrach

@justrach justrach commented Aug 4, 2026

Copy link
Copy Markdown
Owner

Closes #682.

What

codedb_callers reported init(); // then renderX() draws the frame as a call site of renderX — the line starts with code so isCommentOrBlank passes it, and the string filter sees no quotes. Same shape as the string-literal false positives fixed in c23995e, one filter over.

How

New lineCodePrefix truncates each candidate line at its first line-comment marker outside string literals before the whole-word scan runs:

  • marker table mirrors isCommentOrBlank (// C-family/Zig/Rust/Go, # Python/Ruby/R/shell, -- SQL, ! Fortran, ; LLVM IR, HCL both)
  • quoted spans skipped with the same stringLiteralEnd scan, so fetch("https://x", renderX) never truncates
  • shell # only counts at a word start — ${#var} / $# are live syntax
  • mid-line block-comment openers left alone: truncating at /* could drop the real call in foo(); /* … */ bar(); a false negative merely re-admits a mention

Tests

  • issue-682: excludes a symbol mentioned only in a trailing comment — fails on main (committed first, separately, on issue-682-failing-test), passes here
  • issue-682: keeps a call after a string containing the comment marker — guards the URL case
  • Full zig build test green

🤖 Generated with Claude Code

https://claude.ai/code/session_018teBQSh5eSDmojrx12k2jY

justrach and others added 2 commits August 5, 2026 02:13
…ites

hasWholeWordMatchOutsideStrings now scans only the line's code prefix:
lineCodePrefix truncates at the first line-comment marker outside string
literals, using the same language table as isCommentOrBlank and the same
quote-skipping scan as the string filter. Block-comment openers and
backticks stay untouched (false negatives only re-admit mentions), a
string'd "https://…" never truncates, and shell's `#` only counts at a
word start (`${#var}` is live syntax).

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_018teBQSh5eSDmojrx12k2jY

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 1cc30d9402

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/mcp.zig
Comment on lines +2708 to +2711
if (line[i] == '"' or line[i] == '\'') {
if (stringLiteralEnd(line, i)) |end| {
i = end + 1;
continue;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Track raw literals before cutting line comments

When // occurs outside single- or double-quoted strings without opening a line comment, this truncates valid code—for example, const s = https://x`; renderX()in JavaScript/Go orfoo(); /* https://x */ renderX();in C/C++. The prefix ends beforerenderX, so codedb_callers` drops a genuine call site that was reported before this commit; account for backtick/raw/template literals and block-comment spans before accepting a line-comment marker.

Useful? React with 👍 / 👎.

@justrach
justrach merged commit 9695188 into release/0.2.5833-mcp2026 Aug 5, 2026
2 checks passed
@justrach
justrach deleted the fix/issue-682-trailing-comment-callers branch August 5, 2026 02:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant