forked from OSchip/llvm-project
clang-format: [JS] Fix formatting of generator functions.
Before: var x = { a: function* () { // } } After: var x = { a: function*() { // } } llvm-svn: 285670
This commit is contained in:
parent
4d67dd77a1
commit
71e50af675
|
@ -859,7 +859,8 @@ private:
|
|||
if (!CurrentToken->isOneOf(TT_LambdaLSquare, TT_ForEachMacro,
|
||||
TT_FunctionLBrace, TT_ImplicitStringLiteral,
|
||||
TT_InlineASMBrace, TT_JsFatArrow, TT_LambdaArrow,
|
||||
TT_RegexLiteral, TT_TemplateString))
|
||||
TT_OverloadedOperator, TT_RegexLiteral,
|
||||
TT_TemplateString))
|
||||
CurrentToken->Type = TT_Unknown;
|
||||
CurrentToken->Role.reset();
|
||||
CurrentToken->MatchingParen = nullptr;
|
||||
|
|
|
@ -1230,9 +1230,11 @@ void UnwrappedLineParser::tryToParseJSFunction() {
|
|||
// Consume "function".
|
||||
nextToken();
|
||||
|
||||
// Consume * (generator function).
|
||||
if (FormatTok->is(tok::star))
|
||||
// Consume * (generator function). Treat it like C++'s overloaded operators.
|
||||
if (FormatTok->is(tok::star)) {
|
||||
FormatTok->Type = TT_OverloadedOperator;
|
||||
nextToken();
|
||||
}
|
||||
|
||||
// Consume function name.
|
||||
if (FormatTok->is(tok::identifier))
|
||||
|
|
|
@ -384,6 +384,11 @@ TEST_F(FormatTestJS, GeneratorFunctions) {
|
|||
" yield x;\n"
|
||||
" }\n"
|
||||
"}");
|
||||
verifyFormat("var x = {\n"
|
||||
" a: function*() {\n"
|
||||
" //\n"
|
||||
" }\n"
|
||||
"}\n");
|
||||
}
|
||||
|
||||
TEST_F(FormatTestJS, AsyncFunctions) {
|
||||
|
|
Loading…
Reference in New Issue