[PATCH] D42500: [clang-format] Fixes indentation of inner text proto messages
Krasimir Georgiev via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Thu Jan 25 06:12:20 PST 2018
This revision was automatically updated to reflect the committed changes.
Closed by commit rL323419: [clang-format] Fixes indentation of inner text proto messages (authored by krasimir, committed by ).
Herald added a subscriber: llvm-commits.
Repository:
rL LLVM
https://reviews.llvm.org/D42500
Files:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestTextProto.cpp
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -462,13 +462,15 @@
FormatToken *Previous = CurrentToken->getPreviousNonComment();
if (Previous->is(TT_JsTypeOptionalQuestion))
Previous = Previous->getPreviousNonComment();
- if (((CurrentToken->is(tok::colon) &&
- (!Contexts.back().ColonIsDictLiteral || !Style.isCpp())) ||
- Style.Language == FormatStyle::LK_Proto ||
- Style.Language == FormatStyle::LK_TextProto) &&
- (Previous->Tok.getIdentifierInfo() ||
- Previous->is(tok::string_literal)))
- Previous->Type = TT_SelectorName;
+ if ((CurrentToken->is(tok::colon) &&
+ (!Contexts.back().ColonIsDictLiteral || !Style.isCpp())) ||
+ Style.Language == FormatStyle::LK_Proto ||
+ Style.Language == FormatStyle::LK_TextProto) {
+ Left->Type = TT_DictLiteral;
+ if (Previous->Tok.getIdentifierInfo() ||
+ Previous->is(tok::string_literal))
+ Previous->Type = TT_SelectorName;
+ }
if (CurrentToken->is(tok::colon) ||
Style.Language == FormatStyle::LK_JavaScript)
Left->Type = TT_DictLiteral;
Index: cfe/trunk/unittests/Format/FormatTestTextProto.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestTextProto.cpp
+++ cfe/trunk/unittests/Format/FormatTestTextProto.cpp
@@ -289,6 +289,10 @@
" headheadheadheadheadhead_id: 1\n"
" product_data <product {1}>\n"
">");
+
+ verifyFormat("dcccwrnfioeruvginerurneitinfo {\n"
+ " exte3nsionrnfvui {key: value}\n"
+ "}");
}
TEST_F(FormatTestTextProto, DiscardsUnbreakableTailIfCanBreakAfter) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D42500.131430.patch
Type: text/x-patch
Size: 2004 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180125/e7d14fd9/attachment-0001.bin>
More information about the cfe-commits
mailing list