-
Notifications
You must be signed in to change notification settings - Fork 136
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reload DSL compilers in the workspace automatically (#2178)
### Motivation If the user edits custom DSL compilers that exist in the codebase, we never reload them and thus may end up generating incorrect RBI files. This is not a _super_ common scenario as most people aren't working on custom compilers on a regular basis, but we can still perform automatic reloading for them. ### Implementation We do not need to care about compilers defined in gems or in Tapioca itself. If a gem is bumped, the entire LSP is restarted and so we will pick up the changes. So I started paying attention to changes to compilers inside the workspace and then firing a reload notification. The implementation simply lists all descendants of `Tapioca::Dsl::Compiler` that are defined inside of the codebase. Then we proceed to remove the constant, delete the file entry from `$LOADED_FEATURES` and re-require the file to load the current state. **Note** I did not figure out a way to reload DSL extensions. Those are usually used to monkeypatch classes of the application itself or even create constants that don't exist elsewhere, so I'm not sure what we could do that would be guaranteed to work on every case. ### Tests Added a test.
- Loading branch information
Showing
4 changed files
with
99 additions
and
9 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