forked from OSchip/llvm-project
clang-format: [JS] do not insert semicolons after wrapped annotations.
Reviewers: djasper Subscribers: klimek Differential Revision: http://reviews.llvm.org/D18943 llvm-svn: 265916
This commit is contained in:
parent
d8d2f62107
commit
bbffeac569
|
@ -715,6 +715,13 @@ void UnwrappedLineParser::readTokenWithJavaScriptASI() {
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool PreviousMustBeValue = mustBeJSIdentOrValue(Keywords, Previous);
|
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)
|
if (Next->is(tok::exclaim) && PreviousMustBeValue)
|
||||||
addUnwrappedLine();
|
addUnwrappedLine();
|
||||||
bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
|
bool NextMustBeValue = mustBeJSIdentOrValue(Keywords, Next);
|
||||||
|
|
|
@ -686,6 +686,8 @@ TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) {
|
||||||
verifyFormat("x instanceof String", "x\n"
|
verifyFormat("x instanceof String", "x\n"
|
||||||
"instanceof\n"
|
"instanceof\n"
|
||||||
"String");
|
"String");
|
||||||
|
verifyFormat("function f(@Foo bar) {}", "function f(@Foo\n"
|
||||||
|
" bar) {}");
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTestJS, ClosureStyleCasts) {
|
TEST_F(FormatTestJS, ClosureStyleCasts) {
|
||||||
|
|
Loading…
Reference in New Issue