Add go to definition support for through: and class_name: association options#684
Open
sucicfilip wants to merge 1 commit intoShopify:mainfrom
Open
Add go to definition support for through: and class_name: association options#684sucicfilip wants to merge 1 commit intoShopify:mainfrom
through: and class_name: association options#684sucicfilip wants to merge 1 commit intoShopify:mainfrom
Conversation
Member
|
I think the right thing to do is to go to |
875c42b to
86bd4d7
Compare
sucicfilip
commented
Jan 27, 2026
Comment on lines
+127
to
+130
| if class_name_node.is_a?(Prism::StringNode) | ||
| goto_class(class_name_node.content) | ||
| return | ||
| end |
Author
There was a problem hiding this comment.
We can save a server call here.
If an association is defined so that the class_name is explicitly stated, we can just use that instead of making a server call.
through: and class_name: association options
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.
through:optionWhen clicking on the
through:value, it now navigates to the association definition in the same file:This implements the behaviour mentioned in the Rafael's comment below - navigating to the association declaration rather than the model, since
through:references another association, not a model directly.class_name:optionWhen clicking on the
class_name:value, it navigates to that class using the index (no server call needed):Additionally, when clicking on the association name that has a
class_name:specified, it uses the index directly instead of making a server call:This provides a small performance optimization since we can resolve the class name directly from the code without asking Rails for reflection data.
Closes #676