[PATCH] D133589: [clang-format] JSON formatting add new option for controlling newlines in json arrays
Marek Kurdej via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Fri Sep 9 13:38:00 PDT 2022
curdeius added inline comments.
================
Comment at: clang/docs/ClangFormatStyleOptions.rst:3115
+**JsonMultilineArrays** (``Boolean``) :versionbadge:`clang-format 16`
+ If ``true``, clang-format will always break after a Json array `[`
----------------
Why limiting to JSON only?
Could we name it in a general fashion (we comment that it's JSON only for the time being). I believe it may be an interesting option for various languages.
How about BreakMultilineArrays, or just BreakArrays to follow the naming of existing options a bit?
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:4413
+ while (Tok) {
+ if (Tok->isOneOf(tok::l_brace, tok::l_square)) {
+ return true;
----------------
Please elide braces in the ifs.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:4427
+ if (Left.is(tok::comma)) {
+ if (Right.is(tok::l_brace)) {
+ return true;
----------------
You can elide braces here.
================
Comment at: clang/lib/Format/TokenAnnotator.cpp:4434
+ while (Tok) {
+ if (Tok->isOneOf(tok::l_brace, tok::l_square)) {
+ return true;
----------------
You might elide braces in both ifs.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D133589/new/
https://reviews.llvm.org/D133589
More information about the cfe-commits
mailing list