Skip to content

Improve support for ActiveSupport::Concern #491

Open
@andyw8

Description

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 DSLs, 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:

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions