[clang-format] Use SpacesBeforeTrailingComments for "option" directive
Summary: AnnotatingParser::next() is needed to implicitly set TT_BlockComment versus TT_LineComment. On most other paths through AnnotatingParser::parseLine(), all tokens are consumed to achieve that. This change updates one place where this wasn't done. Contributed by @dchai! Reviewers: krasimir Reviewed By: krasimir Subscribers: cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D60541 llvm-svn: 358275
This commit is contained in:
parent
4f789e1b39
commit
69150467b0
|
@ -1124,8 +1124,11 @@ public:
|
||||||
if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
|
if (Style.Language == FormatStyle::LK_Proto && Line.Level == 0 &&
|
||||||
CurrentToken->is(Keywords.kw_option)) {
|
CurrentToken->is(Keywords.kw_option)) {
|
||||||
next();
|
next();
|
||||||
if (CurrentToken && CurrentToken->is(tok::identifier))
|
if (CurrentToken && CurrentToken->is(tok::identifier)) {
|
||||||
|
while (CurrentToken)
|
||||||
|
next();
|
||||||
return LT_ImportStatement;
|
return LT_ImportStatement;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
bool KeywordVirtualFound = false;
|
bool KeywordVirtualFound = false;
|
||||||
|
|
|
@ -193,6 +193,10 @@ TEST_F(FormatTestProto, DoesntWrapFileOptions) {
|
||||||
"\"some.really.long.package.that.exceeds.the.column.limit\";"));
|
"\"some.really.long.package.that.exceeds.the.column.limit\";"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(FormatTestProto, TrailingCommentAfterFileOption) {
|
||||||
|
verifyFormat("option java_package = \"foo.pkg\"; // comment\n");
|
||||||
|
}
|
||||||
|
|
||||||
TEST_F(FormatTestProto, FormatsOptions) {
|
TEST_F(FormatTestProto, FormatsOptions) {
|
||||||
verifyFormat("option (MyProto.options) = {\n"
|
verifyFormat("option (MyProto.options) = {\n"
|
||||||
" field_a: OK\n"
|
" field_a: OK\n"
|
||||||
|
|
Loading…
Reference in New Issue