forked from iftheshoefritz/solargraph-rails
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This a more accurate represenation of what ActiveRecord actually does at runtime, and therefore gives better code suggestions when dealing with associations and model classes. I've settled on this as being the best compromise after trying a few different approaches. There are two "challenges" that I believe can't be met any other way (at this time). 1. It is not possible to write a return type annotation for the methods of various ActiveRecord mixins that will be correct for both a model class (e.g. Person.where) and relation (e.g. people.where). [0], [1] 2. It is not possible to represent ActiveRecords "class methods are also relation methods" behaviour without model-specific relation types. It's conceivable that Solargraph could change it's interpretation of [self] on class methods to solve challenge iftheshoefritz#1, but the second challenge really forces our hand. In order to represent this correctly, Solargraph would need support for method-missing delegation, **and** delegating those missing methods to an associated/generic type. Given @castwide is working on RBS support and the Ruby ecosystem is likely to move that way in the future, it seems pragmatic to eat the cost repetition / manual labour in this gem rather than try to push YARD types into supporting that degree of type-level programming. 😅 [0]: castwide/solargraph#592 [1]: lsegal/yard#1257
- Loading branch information
Showing
4 changed files
with
234 additions
and
37 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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