feat(code-action): add "add to formals" action for undefined variables#777
Merged
Conversation
… vars - Introduce addToFormalsAction to suggest adding undefined variables to the formals list of the nearest enclosing lambda expression - Handle insertion for empty, single, multiple, and ellipsis formals - Only offer the action when the variable is truly undefined and the lambda uses curly-brace formals - Add comprehensive tests for positive and negative scenarios - Register new code action in build system
…ments - Update comments in AddToFormals.cpp to clarify insertion after non-ellipsis formals - Refine documentation in AddToFormals.h for argument style and formals handling
inclyc
approved these changes
Jan 28, 2026
Collaborator
Author
|
Thanks Review!! |
Remove "Step N:" prefixes from comments as they function similarly to line numbers and add unnecessary maintenance overhead for the team. Requested-by: @inclyc
cc3ab86 to
f25d7d9
Compare
3 tasks
2 tasks
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.
Summary
Add code action to add undefined variables to the formals of enclosing lambda expressions.
Example Transformation:
{x}: y{x, y}: y{ }: y{ y }: y{ ... }: y{ y, ... }: y{x, ...}: y{x, y, ...}: yChanges
nixd/lib/Controller/CodeActions/AddToFormals.hnixd/lib/Controller/CodeActions/AddToFormals.cppnixd/lib/Controller/CodeAction.cppnixd/lib/meson.buildBehavior
Action offered when:
{...}: bodyAction NOT offered when:
x: bodyHandles 4 insertion cases:
{ }:→{ y }:{ a }:→{ a, y }:{ ... }:→{ y, ... }:{ a, ... }:→{ a, y, ... }:Test Plan
basic.md: Single existing formalempty-formals.md: Empty formals{ }ellipsis-only.md: Ellipsis-only{ ... }multiple-formals.md: Multiple existing formalswith-ellipsis.md: Formals with ellipsisnested-lambda.md: Nested lambda (adds to innermost)already-defined-negative.md: Negative - variable already in formalsno-formals-negative.md: Negative - simplex: bodysyntaxRelated