Fix local vars & function calls leaking into the document symbols outline#72
Merged
Conversation
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit de7b63f. Configure here.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Closes #69.
Problem
Local variable assignments and ordinary function calls inside a function body were showing up as entries in the document-symbols outline (and in symbol search). For example, a
handle_params/3body containing:...produced bogus
changeset = build_changeset(...)andpaginate_async(...)symbols.Root cause
The outline builder detects ExUnit-style macros (
describe/test/setup) by scanning forward from a leading identifier to see if adoblock follows. It usedScanForwardToBlockDo, which intentionally does not stop at end-of-line (to allow split-line heads) and only halts atdef/end-style keywords. So for a plain assignment, the scan sailed across statement boundaries and latched onto thedoof a latercase, making the assignment look like a macro-with-do-block.The reference-collecting parser already had a careful scan that tracks bracket depth and statement boundaries — but the outline code never shared it.
Fix
ScanForwardToMacroCallBlockDohelper: adoonly counts at bracket depth 0, and once an end-of-line is seen at depth 0, any non-dotoken ends the statement and stops the scan.defmodule/defcall sites keep usingScanForwardToBlockDo— there the keyword itself is a statement boundary, so the naive scan is correct.Bonus: multi-line macro heads now detected
While here, also fixed a pre-existing limitation: an ExUnit macro whose keyword-argument head spans multiple lines was not detected:
A trailing comma at bracket depth 0 is an unambiguous continuation in Elixir (a statement can't end on a dangling comma), so the scan now continues across it — while
=stays a boundary, keeping the #69 fix intact. Multi-line head labels also collapse internal whitespace so they render on a single line in the outline.Note
Low Risk
Changes are localized to token forward-scanning and document-symbol labeling, with broad unit/LSP tests and no auth or persistence impact.
Overview
Fixes document symbol outline false positives where assignments and plain calls inside a function were treated as ExUnit-style macros because a forward scan crossed statement boundaries and matched a later
case … do.The outline and reference parser now share
ScanForwardToMacroCallBlockDo: at bracket depth 0, end-of-line ends the macro head unless the line ends with a trailing comma (multi-linetest/describeheads), anddoinside nested parens/brackets does not count.defmodule/defstill useScanForwardToBlockDo.Macro outline labels collapse whitespace between the name and
doso split-line keyword args show as one line. Regression tests cover issue #69 and multi-line macro heads.Reviewed by Cursor Bugbot for commit 3fcd711. Bugbot is set up for automated code reviews on this repo. Configure here.