-
-
Notifications
You must be signed in to change notification settings - Fork 48
Proposal: cli: Implement rbs_rails server
command (prototype)
#338
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
Draft
tk0miya
wants to merge
6
commits into
pocke:master
Choose a base branch
from
tk0miya:cli_server
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
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
312eeab
to
4daefc4
Compare
6f8600f
to
0e049fe
Compare
tk0miya
commented
Aug 30, 2025
lib/rbs_rails/cli/server/handler.rb
Outdated
Comment on lines
132
to
133
sig = RbsRails::ActiveRecord.class_to_rbs(klass) | ||
rbs_path.write sig |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The type signature should be rewritten only if its content has been changed. At present, the reloading cost of Steep is high. It would be better not to change its timestamp if nothing changed.
At present, steep detect the file change via its timestamp. To avoid unnecessary type check, this adds FileWriter class which updates the RBS file only if its content has changed.
So far, our testcases build RBS signatures from scratch every time. It is slow and unnecessary. This introduces a mechanism to share the built signatures across tests. Before: ``` Finished in 99.189478s, 0.2016 runs/s, 0.1815 assertions/s. 20 runs, 18 assertions, 0 failures, 0 errors, 0 skips ``` After: ``` Finished in 25.321047s, 0.7899 runs/s, 0.7109 assertions/s. 20 runs, 18 assertions, 0 failures, 0 errors, 0 skips ```
ActiveRecord::* and ActiveStorage::* are parts of Ruby on Rails, and their types are distributed on the gem_rbs_collection repo. Therefore, there is no reason to generate types for them.
As a preparation for LSP server, this integrates model_dependencies.rbs to each model signatures. With this change, the signature of dependencies will be separated to the each RBS file of the model. It allows to rbs_rails to generate signatures for models one by one, not only the whole of application. It also helps the LSP server generate signatures on the fly.
To make RBS generation faster to extract signatures from the Ruby on Rails application, this provides the rbs_rails LSP server. It generates signatures on demand if the IDE lets the rbs_rails LSP server know the changes to Ruby files. It preloads the Rails application on start and reloads it when the source code is changed. It improves the performance of signature generation rather than running the rbs_rails command
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.
To make RBS generation faster to extract signatures from the Ruby on
Rails application, this provides the rbs_rails LSP server. It generates
signatures on demand if the IDE lets the rbs_rails LSP server know the
changes to Ruby files.
It preloads the Rails application on start and reloads it when the
source code is changed. It improves the performance of signature
generation rather than running the rbs_rails command
This is a demo movie for this LSP server. I used my RBS helper extension to invoke the server.
The types for models are updated automatically and seamlessly upon editing, database migration, and other similar events.
2025-08-23.17.13.49.mov
Note: this contains #345