Skip to content

feat: follow defdelegates wrapped by macros#26

Open
cfbender wants to merge 1 commit intoremoteoss:mainfrom
cfbender:feat/follow-macro-defdelegates
Open

feat: follow defdelegates wrapped by macros#26
cfbender wants to merge 1 commit intoremoteoss:mainfrom
cfbender:feat/follow-macro-defdelegates

Conversation

@cfbender
Copy link
Copy Markdown

@cfbender cfbender commented Apr 13, 2026

I'll give the same AI disclosure as another issue, the code here was mostly AI-written, but was heavily iterated and reviewed by me. Feel free to close if it's just noise.

Motivation

We were trying out dexter today on our team, and it is fantastic for us except that we have some macros that wrap defdelegate, which elixir-ls was following but dexter was not. I wanted to take a crack at getting it to follow, and this is the result.

Implementation

Originally, the first pass was looking for macros that use to: in the macro options, but I thought this would likely be too fragile with things like plugs or any other macro that could use the same option.

The only robust way seemed to be scanning the actual implementation for utilizing defdelegate directly.

This resulted in a bigger diff than I was hoping for, but I tested it with our custom macro and it's working beautifully.

Alternatives

I also tried a more specific implementation with indexing wrapped defdelegates in order to keep the hot path a little tighter, but it seemed a little over-opinionated on defdelegate specifically. I think it could be worth revisiting if it's something you think makes more sense for this project

Again please feel free to not accept, or open to any suggestions here!

@cfbender cfbender force-pushed the feat/follow-macro-defdelegates branch from 17d2af0 to a732d9f Compare April 13, 2026 20:32
@JesseHerrick
Copy link
Copy Markdown
Collaborator

Hi @cfbender, thank you for the contribution! I definitely did not consider that people would be adding defdelegates via macros (a bit too much macro magic for my taste 😄). But of course, anything is possible with macros!

I'm absolutely open to the contribution, but I'd like to get #22 merged in first, which has a massive change to the way that we parse files and handle lookups. After that, you'll need to update the approach here a bit to use tokens rather than chars. But I think that this will actually be easier with the token based approach.

@cfbender
Copy link
Copy Markdown
Author

sounds perfect to me, thanks so much! and yeah, it is a bit messy - for context we mostly do it so we don't have to maintain the arguments in two places.

I'll keep an eye on 22 and get this updated when that's ready!

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