[PATCH] D44203: [clang-format] Improve Incomplete detection for (text) protos
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Apr 5 03:29:59 PDT 2018
krasimir added inline comments.
================
Comment at: lib/Format/TokenAnnotator.cpp:665
}
+ if ((Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) &&
----------------
sammccall wrote:
> I don't really understand what this is doing.
> It seems to be detecting some particular sequence of invalid tokens `}:`,`]:`,`>:`. Why are these special?
>
> What's the contract of consumeToken()? It's hard to see from the callsites.
Thank you very much! I guess I got carried away. These don't make sense. I'll update it to only keep dangling `:` as in `key:`.
Returning false from consumeToken has the desired effect that (eventually) marks the line as incomplete here:
https://github.com/llvm-mirror/clang/blob/master/lib/Format/TokenAnnotator.cpp#L1055
================
Comment at: lib/Format/TokenAnnotator.cpp:773
case tok::r_brace:
- // Lines can start with '}'.
- if (Tok->Previous)
+ // Lines can start with '}' except in text protos.
+ if (Tok->Previous || Style.Language == FormatStyle::LK_TextProto)
----------------
sammccall wrote:
> In what sense of "line" is this true?
This is the UnwrappedLine concept of clang-format: roughly a maximal sequence of tokens that we could have put on the same line if there was no column limit.
Repository:
rC Clang
https://reviews.llvm.org/D44203
More information about the cfe-commits
mailing list