Skip to content

fix: alias handling for multi-line declarations#19

Closed
joaopsramos wants to merge 3 commits intoremoteoss:mainfrom
joaopsramos:fix/multi-line-aliases
Closed

fix: alias handling for multi-line declarations#19
joaopsramos wants to merge 3 commits intoremoteoss:mainfrom
joaopsramos:fix/multi-line-aliases

Conversation

@joaopsramos
Copy link
Copy Markdown

@joaopsramos joaopsramos commented Apr 11, 2026

Hi! First of all, thanks for the project!

This PR fixes a bug where multi-line alias declarations were not parsed correctly:

  1. as: on the next line:

    alias MyApp.Accounts,
      as: Accounts
  2. Braces opening on one line with entries on subsequent lines:

    alias MyApp.{
      Accounts,
      Users,
      Profiles
    }

Note

Medium Risk
Parsing logic for Elixir aliases is expanded to look ahead across lines and collect brace blocks, which could subtly change reference resolution for some files. Changes are well-covered by new tests but touch core LSP/parser extraction paths.

Overview
Fixes Elixir alias extraction so multi-line alias forms are recognized and resolved: alias Mod, with as: on the following line, and alias Parent.{ with children listed on subsequent lines.

This updates both the LSP alias scanners and the core parser.ParseText alias/reference extraction (including a shared CollectBraceContent helper), and adds regression tests to ensure alias refs and subsequent call resolution work for these multi-line patterns.

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

@JesseHerrick
Copy link
Copy Markdown
Collaborator

Thanks for the PR and bug report! I hadn't encountered this before because I was testing on repos where Styler removes these types of aliases. I was able to replicate this myself too and will take a look at your solution when I have a chance.

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 1 potential issue.

Fix All in Cursor

Reviewed by Cursor Bugbot for commit b754fef. Configure here.

@joaopsramos
Copy link
Copy Markdown
Author

Closing in favor of #22

@JesseHerrick
Copy link
Copy Markdown
Collaborator

Hey @joaopsramos, thanks again for the PR! While indeed we are going to go with #22, your PR made me think through this problem a little bit more and I realized that it was time to implement a proper token-based approach over regex since it solves this issue and many more. Once #22 is merged, we will have even better accuracy and this issue will be fixed.

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.

2 participants