forked from OSchip/llvm-project
clang-format: [JS] Understand named function literals.
Before: return {a: function SomeFunction(){// ... return 1; } } ; After: return { a: function SomeFunction() { // ... return 1; } }; llvm-svn: 210887
This commit is contained in:
parent
5ef4fe7d8e
commit
5217a8b84f
|
@ -907,6 +907,11 @@ bool UnwrappedLineParser::tryToParseLambdaIntroducer() {
|
|||
|
||||
void UnwrappedLineParser::tryToParseJSFunction() {
|
||||
nextToken();
|
||||
|
||||
// Consume function name.
|
||||
if (FormatTok->is(tok::identifier))
|
||||
nextToken();
|
||||
|
||||
if (FormatTok->isNot(tok::l_paren))
|
||||
return;
|
||||
nextToken();
|
||||
|
|
|
@ -138,7 +138,7 @@ TEST_F(FormatTestJS, GoogScopes) {
|
|||
"}); // goog.scope");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJS, Closures) {
|
||||
TEST_F(FormatTestJS, FunctionLiterals) {
|
||||
verifyFormat("doFoo(function() { return 1; });");
|
||||
verifyFormat("var func = function() { return 1; };");
|
||||
verifyFormat("return {\n"
|
||||
|
@ -177,6 +177,13 @@ TEST_F(FormatTestJS, Closures) {
|
|||
" a: function() { return 1; }\n"
|
||||
"};",
|
||||
getGoogleJSStyleWithColumns(37));
|
||||
|
||||
verifyFormat("return {\n"
|
||||
" a: function SomeFunction() {\n"
|
||||
" // ...\n"
|
||||
" return 1;\n"
|
||||
" }\n"
|
||||
"};");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJS, MultipleFunctionLiterals) {
|
||||
|
|
Loading…
Reference in New Issue