clang-format: [JS] Support for EC6 arrow functions.

Before:
  var b = a.map((x) = > x + 1);

After:
  var b = a.map((x) => x + 1);

llvm-svn: 209112
This commit is contained in:
Daniel Jasper 2014-05-19 07:27:02 +00:00
parent 993a906af3
commit 78214397a3
2 changed files with 5 additions and 0 deletions

View File

@ -1244,6 +1244,7 @@ private:
static tok::TokenKind JSNotIdentity[] = { tok::exclaimequal, tok::equal };
static tok::TokenKind JSShiftEqual[] = { tok::greater, tok::greater,
tok::greaterequal };
static tok::TokenKind JSRightArrow[] = { tok::equal, tok::greater };
// FIXME: We probably need to change token type to mimic operator with the
// correct priority.
if (tryMergeTokens(JSIdentity))
@ -1252,6 +1253,8 @@ private:
return;
if (tryMergeTokens(JSShiftEqual))
return;
if (tryMergeTokens(JSRightArrow))
return;
}
}

View File

@ -77,6 +77,8 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
" bbbbbb :\n"
" ccc;",
getGoogleJSStyleWithColumns(20));
verifyFormat("var b = a.map((x) => x + 1);");
}
TEST_F(FormatTestJS, SpacesInContainerLiterals) {