Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve support for ActiveSupport::Concern #491

Open
andyw8 opened this issue Oct 22, 2024 · 0 comments
Open

Improve support for ActiveSupport::Concern #491

andyw8 opened this issue Oct 22, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@andyw8
Copy link
Contributor

andyw8 commented Oct 22, 2024

Note

This issue is aimed at those attending the RubyConf 2024 Hack Day

Caution

This will likely be a difficult issue, please discuss approaches with the maintainers before attempting.

For ActiveRecord model, you'll notice that you can hover over some DSLss, such as has_one:, to see its documentation, but if you others, such as validates:, nothing is shown.

This is because the ActiveModel::Validations::Callbacks module is mixed into the parent’s class using an included block:

https://github.com/rails/rails/blob/d4fff28caf25546dfef68087047af34927a3d5f0/activerecord/lib/active_record/callbacks.rb#L413

As this a Rails feature, it is not supported by Ruby LSP natively.

It should be possible to support this via an Indexing Enhancement in the Rails addon so that the index knows about ActiveModel::Validations::Callbacks, and Ruby LSP will then be able to show the documentation on hover.

Also, since included can be used in application code, this will improve Ruby's LSP's ability to provide features for your app.

There is partial support for concerns in indexing_enhancement.rb but it doesn't yet know about included.

(Note that there can also be a prepended block).

These articles may help with understanding the details of concerns:

@andyw8 andyw8 added enhancement New feature or request railsconf-hackday Issues intented for working on during RailsConf 2024 Hack Day labels Oct 22, 2024
@andyw8 andyw8 removed the railsconf-hackday Issues intented for working on during RailsConf 2024 Hack Day label Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant