[PATCH] D18943: clang-format: [JS] do not insert semicolons after wrapped annotations.
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Sun Apr 10 22:23:51 PDT 2016
mprobst updated this revision to Diff 53190.
mprobst added a comment.
- simplify conditions
http://reviews.llvm.org/D18943
Files:
lib/Format/UnwrappedLineParser.cpp
unittests/Format/FormatTestJS.cpp
Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -686,6 +686,8 @@
verifyFormat("x instanceof String", "x\n"
"instanceof\n"
"String");
+ verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
+ " bar) {}");
}
TEST_F(FormatTestJS, ClosureStyleCasts) {
Index: lib/Format/UnwrappedLineParser.cpp
===================================================================
--- lib/Format/UnwrappedLineParser.cpp
+++ lib/Format/UnwrappedLineParser.cpp
@@ -715,6 +715,13 @@
return;
bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
+ if (PreviousMustBeValue && Line && Line->Tokens.size() > 1) {
+ // If the token before the previous one is an '@', the previous token is an
+ // annotation and can precede another identifier/value.
+ const FormatToken *PrePrevious = std::next(Line->Tokens.rend(), 2)->Tok;
+ if (PrePrevious->is(tok::at))
+ return;
+ }
if (Next->is(tok::exclaim) && PreviousMustBeValue)
addUnwrappedLine();
bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D18943.53190.patch
Type: text/x-patch
Size: 1301 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160411/577080af/attachment.bin>
More information about the cfe-commits
mailing list