forked from OSchip/llvm-project
clang-format: [JS] Better support for empty function literals.
Before: SomeFunction(function(){}); After: SomeFunction(function() {}); llvm-svn: 217236
This commit is contained in:
parent
97bfb7b1ba
commit
3f69ba1075
|
@ -1041,6 +1041,13 @@ void UnwrappedLineParser::parseParens() {
|
||||||
if (FormatTok->Tok.is(tok::l_brace))
|
if (FormatTok->Tok.is(tok::l_brace))
|
||||||
parseBracedList();
|
parseBracedList();
|
||||||
break;
|
break;
|
||||||
|
case tok::identifier:
|
||||||
|
if (Style.Language == FormatStyle::LK_JavaScript &&
|
||||||
|
FormatTok->TokenText == "function")
|
||||||
|
tryToParseJSFunction();
|
||||||
|
else
|
||||||
|
nextToken();
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
nextToken();
|
nextToken();
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -167,6 +167,7 @@ TEST_F(FormatTestJS, FormatsFreestandingFunctions) {
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(FormatTestJS, FunctionLiterals) {
|
TEST_F(FormatTestJS, FunctionLiterals) {
|
||||||
|
verifyFormat("doFoo(function() {});");
|
||||||
verifyFormat("doFoo(function() { return 1; });");
|
verifyFormat("doFoo(function() { return 1; });");
|
||||||
verifyFormat("var func = function() { return 1; };");
|
verifyFormat("var func = function() { return 1; };");
|
||||||
verifyFormat("return {\n"
|
verifyFormat("return {\n"
|
||||||
|
|
Loading…
Reference in New Issue