Shopify / Shopify/ruby-lsp-rails

Improve support for `ActiveSupport::Concern`

Open
#491 1 comment 0 reactions 1 assignee View on GitHub

@andyw8 is already working on this.

Since Dec 17, 2024.

enhancement help-wanted
Dominant language
Ruby
Stars
688
Forks
44
PR merge metrics
No merged PRs in 30d

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:

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.