Repository navigation
Hug single block lambda arguments on the first line of dereference chains with an extra +4 indent, matching expression lambdas. - #1548
Merged
Conversation
…ains with an extra `+4` indent, matching expression lambdas. Previously, calls staying on the first line of a dereference chain with trailing dereferences hugged single expression lambdas with `+4` (`huggedPlusIndent`), while suppressing hugging altogether for single block lambdas via `notHuggable`/`doNotHug`. That left block lambdas inconsistent with expression lambdas, inconsistent across the 4-character receiver break threshold (e.g. `item.withCallback(...)` vs. `someLongReceiverName` breaking before `.withCallback(...)`), and inconsistent between the chain head and subsequent chained calls. This change unifies block and expression lambdas under `huggedPlusIndent`, removing `notHuggable`, `doNotHug`, and `hasHuggedBlockLambda` and replacing the remaining class-body suppression with an explicit `allowBlockLambdaHug` parameter on `addArguments`. It also propagates `huggedPlusIndent` through `visitNewClass` for chained constructor calls, avoids double-indenting when the chain already broke at an earlier dot or type argument list, and covers chains where a prefix element is followed by a trailing dereference (e.g. `MyClass.computeItems(...).stream()`). PiperOrigin-RevId: 1031175750
copybara-service
Bot
force-pushed
the
test_1024089518
branch
from
November 27, 2026 12:05
a1a4e00 to
eb7bc9a
Compare
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.
Hug single block lambda arguments on the first line of dereference chains with an extra
+4indent, matching expression lambdas.Previously, calls staying on the first line of a dereference chain with trailing dereferences hugged single expression lambdas with
+4(huggedPlusIndent), while suppressing hugging altogether for single block lambdas vianotHuggable/doNotHug. That left block lambdas inconsistent with expression lambdas, inconsistent across the 4-character receiver break threshold (e.g.item.withCallback(...)vs.someLongReceiverNamebreaking before.withCallback(...)), and inconsistent between the chain head and subsequent chained calls.This change unifies block and expression lambdas under
huggedPlusIndent, removingnotHuggable,doNotHug, andhasHuggedBlockLambdaand replacing the remaining class-body suppression with an explicitallowBlockLambdaHugparameter onaddArguments. It also propagateshuggedPlusIndentthroughvisitNewClassfor chained constructor calls, avoids double-indenting when the chain already broke at an earlier dot or type argument list, and covers chains where a prefix element is followed by a trailing dereference (e.g.MyClass.computeItems(...).stream()).