Repository navigation
Support multi-arity functions in cljr-change-function-signature - #594
Merged
Merged
Conversation
Building on the tagged add/remove model, the command now handles multi-arity defns. It prompts for which arity to change (cljr--choose-arity over cljr--get-function-arities) and edits just that one: the definition's matching lambda list plus the call sites whose argument count matches. cljr--goto-arity-lambda-list navigates to the lambda list of the arity with a given parameter count, handling both bare single-arity lists and multi-arity clauses. The classifier matches each call site's arg count (cljr--call-site-arg-count) against the edited arity, leaving calls to other arities untouched; variadic and apply/partial sites still route to the manual-intervention buffer. The single-arity path now flows through the same arity-navigation and arg-count matching, with the arity always matching. Validated live against a real refactor-nrepl connection: reordering a chosen arity swapped its lambda list, an internal recursive call, and external calls of that arity, while the other arity and its call sites were untouched.
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
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.
Follow-up to the add/remove work:
cljr-change-function-signaturenow handles multi-arity functions instead of erroring on them.It asks which arity you want to change, then updates only that arity - its definition lambda list and the call sites with a matching argument count. Call sites of other arities are left alone (matched by counting args); variadic and
apply/partialsites still go to manual review. To change several arities, run it once per arity.The single-arity path now flows through the same arity-navigation and arg-count matching (the sole arity always matches), so nothing regresses there.
Validated live against a real refactor-nrepl connection: reordering a chosen arity swapped its lambda list, an internal recursive call, and external calls of that arity, while the other arity and its 1-arg call sites were left untouched. Plus buttercup coverage for the navigation/counting/selection helpers and the multi-arity definition edit, and ecukes coverage for the arity-matched call-site routing.
Design doc (
doc/design/change-function-signature.md) updated - this closes out P2.