[clang-format] Fixup a case of text proto message attributes
Summary: This patch fixes a case where a proto message attribute is wrongly identified as an text proto extension. Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D43465 llvm-svn: 325509
This commit is contained in:
parent
b040fcc693
commit
9b2aa42f00
|
@ -375,6 +375,10 @@ private:
|
|||
// (aaa) = aaa
|
||||
// ];
|
||||
//
|
||||
// extensions 123 [
|
||||
// (aaa) = aaa
|
||||
// ];
|
||||
//
|
||||
// or text proto extensions (in options):
|
||||
//
|
||||
// option (Aaa.options) = {
|
||||
|
@ -394,6 +398,8 @@ private:
|
|||
Left->Type = TT_ArrayInitializerLSquare;
|
||||
if (!Left->endsSequence(tok::l_square, tok::numeric_constant,
|
||||
tok::equal) &&
|
||||
!Left->endsSequence(tok::l_square, tok::numeric_constant,
|
||||
tok::identifier) &&
|
||||
!Left->endsSequence(tok::l_square, tok::colon, TT_SelectorName)) {
|
||||
Left->Type = TT_ProtoExtensionLSquare;
|
||||
BindingIncrease = 10;
|
||||
|
|
|
@ -168,6 +168,16 @@ TEST_F(FormatTestProto, MessageFieldAttributes) {
|
|||
" aaaaaaaaaaaaaaaa: true\n"
|
||||
" }\n"
|
||||
"];");
|
||||
verifyFormat("extensions 20 [(proto2.type) = 'Aaaa.bbbb'];");
|
||||
verifyFormat("extensions 20\n"
|
||||
" [(proto3.type) = 'Aaaa.bbbb', (aaa.Aaa) = 'aaa.bbb'];");
|
||||
verifyFormat("extensions 123 [\n"
|
||||
" (aaa) = aaaa,\n"
|
||||
" (bbbbbbbbbbbbbbbbbbbbbbbbbb) = {\n"
|
||||
" aaaaaaaaaaaaaaaaa: true,\n"
|
||||
" aaaaaaaaaaaaaaaa: true\n"
|
||||
" }\n"
|
||||
"];");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestProto, DoesntWrapFileOptions) {
|
||||
|
|
Loading…
Reference in New Issue