Repository navigation
feat: break long throws clauses one exception per line - #1097
devilking7x wants to merge 2 commits into
Conversation
When a throws clause with multiple exception types does not fit on one line, break after the throws keyword with one exception per line, and place the body block on its own line to separate it from the exceptions. Closes jhipster#591
… tests - Replace conditionalGroup with an equivalent plain group in the throws printer. Output is byte-identical across all 86 unit-test fixtures, and this avoids conditionalGroup, which Prettier documents as a last resort due to exponential complexity when nested. - Use a shared Symbol for the throws group id instead of a string, fixing the tsc errors (prettier's types require symbol group ids). - Add test coverage for uncovered edge cases: a single very long exception name, generic exception types, nested classes, interface methods and default methods with breaking throws clauses. 226/226 unit tests pass; eslint, tsc, prettier and 5x idempotency clean.
|
Hi — following today's review discussion on #1041, I wanted to note that this PR implements the #591 design you described there: when a I verified the output against the expected output posted in #591 — all 6 examples format character-for-character identical. The latest commit also: replaces 226/226 unit tests pass; eslint, tsc, prettier format check, and 5× idempotency all clean. |
|
Closing in favor of #591. |
Closes #591.
What
Long
throwsclauses now break one exception per line when they don't fit, instead of staying on one long line. When the clause breaks, the body{moves onto its own line — separating the throws clause from the body contents (the exact indentation-confusion case from #429).This implements the #591 design: one exception per line when broken,
{on its own line. Follows the Prettier TypeScriptimplements-clause precedent referenced in #591.Implementation
throwsprinter uses a plaingroup— one line when it fits, one-exception-per-line when broken (verified byte-identical output vsconditionalGroupacross all 86 unit-test fixtures; plaingroupavoids the construct flagged as last-resort in the fix: break long throws clauses one exception per line #1041 review)method_declarationandconstructor_declarationdrop the body{to its own line only whenthrowsbreakssymbolgroup ids (prettier's types requiresymbol; fixes thetscerrors from string ids)Testing
tscclean, Prettier format check clean, 5× idempotency clean