feat: add module rename support #284
Open
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.
Context
While AI-assisted renaming is convenient, it's still slower than a native Language Server implementation. This PR ports the module rename feature from Lexical PR #636, which I've been using reliably for almost two years. Given that the Lexical repository is now archived, I wanted to bring this practical and well-tested feature to Expert.
Changes
Core Implementation (engine)
Engine.CodeMod.Renamemodule with submodules:Prepare,Module,Entry,File, andDiffEngine.Commands.RenameGenServer for tracking rename progress and triggering reindexEngine.Commands.RenameSupervisorfor managing rename command lifecycleLSP Integration (expert)
PrepareRenameandRenamehandlers for LSP protocolExpert.EngineApiwithprepare_rename/3andrename/5APIsrename_providerwithprepare_provider: truein server capabilitiesInfrastructure (forge)
RenameFilestruct toForge.Document.Changesfor file rename operationsfile_changedandfile_savedmessage types toForge.EngineApi.MessagesKey Differences from Lexical
:erpc.callviaExpert.EngineApi.call/4instead ofRemoteControl.callLexical.RemoteControl.*→Engine.*,Lexical.Server.*→Expert.*Why These Changes
Progress tracking & reindex (
59953157): Without reindexing after rename, the search index retains old module names. This causes subsequent renames to fail - e.g., renamingAccounts→Accounts2works, but renaming back fails because the index doesn't reflect the new names.Temporary document opening (
f08fd155): After a file rename, the new URI may not exist inDocument.Store, causing "not_open" errors during reindex. Addedensure_open/1to temporarily open files from disk when needed.Expanded test coverage (
a38652ef): Added comprehensive tests covering references, descendants, structs, edge cases, and file renaming with realistic module names.Extra
A demo video is attached showing the smooth rename workflow - renaming a module and then renaming it back. Tested successfully in both VSCode and Neovim.
CleanShot.2026-01-04.at.15.43.19.mp4