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:
Daniel Jasper 2016-11-01 06:22:59 +00:00
parent 4d67dd77a1
commit 71e50af675
3 changed files with 11 additions and 3 deletions

View File

@ -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;

View File

@ -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))

View File

@ -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) {