Skip to content

Fix parser: handle multi-line and edge case parsing#21

Closed
JesseHerrick wants to merge 2 commits intomainfrom
fix/parser-edge-cases
Closed

Fix parser: handle multi-line and edge case parsing#21
JesseHerrick wants to merge 2 commits intomainfrom
fix/parser-edge-cases

Conversation

@JesseHerrick
Copy link
Copy Markdown
Collaborator

@JesseHerrick JesseHerrick commented Apr 12, 2026

Fixes the issues raised in #19, but takes it a step further to fix all multi-line parsing issues. Also fixes issues with hover-docs and completions inside of a multi-line alias block.


Note

Medium Risk
Touches core parsing/indexing and LSP resolution paths (aliases/uses/hover/completion/definition), so regressions could affect navigation and symbol indexing across many files, though changes are well-covered by new regression tests.

Overview
Improves Elixir parsing robustness by joining continued lines and multi-line directives (backslash continuations, unclosed brackets, and trailing-comma alias/use/import/require forms) while preserving original line numbers, and adds stronger skipping of sigils/strings/interpolations/char literals to avoid false refs/defs and heredoc mis-detection.

Enhances LSP behavior for multi-line alias brace blocks by detecting the parent module (ExtractAliasBlockParent) and using it to resolve modules for hover/definition/references and to offer module-segment completions inside alias Parent.{ ... }; also avoids completions after func()./var. where type info is unavailable. Adds support for parsing multi-line use opts, introduces a periodic background reindex, and bumps IndexVersion to invalidate old indexes.

Reviewed by Cursor Bugbot for commit 1ecda73. Bugbot is set up for automated code reviews on this repo. Configure here.

@JesseHerrick JesseHerrick force-pushed the fix/parser-edge-cases branch from 7645182 to 86c6500 Compare April 12, 2026 23:47
@JesseHerrick JesseHerrick force-pushed the fix/parser-edge-cases branch from 86c6500 to 03cc708 Compare April 12, 2026 23:50
Copy link
Copy Markdown

@cursor cursor bot left a comment

Choose a reason for hiding this comment

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

Cursor Bugbot has reviewed your changes and found 2 potential issues.

Fix All in Cursor

❌ 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 03cc708. Configure here.

}
// Any other statement means we've left the alias context
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.

Non-alias lines never break backward scan despite comment

Medium Severity

In ExtractAliasBlockParent, the backward scan at lines 204–211 has a comment saying "Any other statement means we've left the alias context" but the code just continues instead of returning ("", false). Both the blank-line branch and the non-blank non-alias branch do continue, so a non-alias statement (e.g., an import or assignment) between the alias block opener and the cursor won't stop the scan. The pre-check partially mitigates this for def/defp/defmodule, but other statements like import, require, or plain code won't break the backward scan, potentially causing a false positive match to an unrelated alias block further up.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 03cc708. Configure here.

}

// looksLikeOptContinuation returns true if the trimmed line looks like a
// keyword list continuation (e.g. "name: \"foo\"", "permissions: :inherited").
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Stale dangling doc comment for removed function

Low Severity

There's an orphaned doc comment for looksLikeOptContinuation — a function that doesn't exist in this file. It appears the function was replaced by parser.LooksLikeKeywordOpt, but its doc comment was left behind as a floating comment block between ExtractUsesWithOpts and ParseKeywordModuleOpts.

Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit 03cc708. Configure here.

@JesseHerrick
Copy link
Copy Markdown
Collaborator Author

Closing because #22 includes these changes but is a better fix.

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