forked from OSchip/llvm-project
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:
parent
993a906af3
commit
78214397a3
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in New Issue