Skip to content

Hug single block lambda arguments on the first line of dereference chains with an extra +4 indent, matching expression lambdas. - #1548

Merged
copybara-service[bot] merged 1 commit into
masterfrom
test_1024089518
Nov 27, 2026
Merged

copybara-service[bot] merged 1 commit into
masterfrom
test_1024089518

Conversation

@copybara-service

Copy link
Copy Markdown

Hug single block lambda arguments on the first line of dereference chains 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()).

…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
copybara-service Bot merged commit eb7bc9a into master Nov 27, 2026
12 checks passed
@copybara-service
copybara-service Bot deleted the test_1024089518 branch November 27, 2026 12:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant