Renaming a strict local should be a rename, not a find-and-replace. Putting the cursor on user and pressing F2 in a partial should rename the declaration, every reference in the template, and the user: key at every render call site that passes it.
app/views/users/_card.html.erb
<%# locals: (user:) %>
<h1><%= user.name %></h1>
<p><%= user.bio %></p>
app/views/users/show.html.erb
<%= render partial: "users/card", locals: { user: @user } %>
Renaming user to author has to touch both files:
<%# locals: (author:) %>
<h1><%= author.name %></h1>
<p><%= author.bio %></p>
<%= render partial: "users/card", locals: { author: @user } %>
The in-file half alone is worse than not offering the rename at all. A required local that gets renamed in the declaration and nowhere else raises ActionView::StrictLocalsError on the next render, the same failure the actionview-no-strict-locals-error rule (#639) should be reporting.
What already works
The parser already provides both ends of the edit.
Declarations come from ERBStrictLocalsNode.locals, a list of RubyParameterNode with a name token, so the declaration side needs no new parsing.
Call sites come from render_nodes: true, which turns a render call into an ERBRenderNode with keywords.partial and keywords.locals, each a RubyRenderLocalNode with its own name token:
<%= render partial: "users/card", locals: { user: @user, size: "sm" } %>
partial: "users/card"
local: user cols 44–49
local: size cols 57–62
One thing to watch on both sides: the name token's location includes the trailing colon, so user is four characters but spans five columns. A rename that replaces the token's full range eats the : and produces locals: (author).
Renaming a strict local should be a rename, not a find-and-replace. Putting the cursor on
userand pressing F2 in a partial should rename the declaration, every reference in the template, and theuser:key at everyrendercall site that passes it.app/views/users/_card.html.erbapp/views/users/show.html.erbRenaming
usertoauthorhas to touch both files:The in-file half alone is worse than not offering the rename at all. A required local that gets renamed in the declaration and nowhere else raises
ActionView::StrictLocalsErroron the next render, the same failure theactionview-no-strict-locals-errorrule (#639) should be reporting.What already works
The parser already provides both ends of the edit.
Declarations come from
ERBStrictLocalsNode.locals, a list ofRubyParameterNodewith anametoken, so the declaration side needs no new parsing.Call sites come from
render_nodes: true, which turns arendercall into anERBRenderNodewithkeywords.partialandkeywords.locals, each aRubyRenderLocalNodewith its own name token:One thing to watch on both sides: the name token's location includes the trailing colon, so
useris four characters but spans five columns. A rename that replaces the token's full range eats the:and produceslocals: (author).