Skip to content
Snippets Groups Projects
Commit f805b0c2 authored by Daniel Jasper's avatar Daniel Jasper
Browse files

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

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

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

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@209112 91177308-0d34-0410-b5e6-96231b3b80d8
parent cea7244f
No related branches found
No related tags found
No related merge requests found
...@@ -1244,6 +1244,7 @@ private: ...@@ -1244,6 +1244,7 @@ private:
static tok::TokenKind JSNotIdentity[] = { tok::exclaimequal, tok::equal }; static tok::TokenKind JSNotIdentity[] = { tok::exclaimequal, tok::equal };
static tok::TokenKind JSShiftEqual[] = { tok::greater, tok::greater, static tok::TokenKind JSShiftEqual[] = { tok::greater, tok::greater,
tok::greaterequal }; tok::greaterequal };
static tok::TokenKind JSRightArrow[] = { tok::equal, tok::greater };
// FIXME: We probably need to change token type to mimic operator with the // FIXME: We probably need to change token type to mimic operator with the
// correct priority. // correct priority.
if (tryMergeTokens(JSIdentity)) if (tryMergeTokens(JSIdentity))
...@@ -1252,6 +1253,8 @@ private: ...@@ -1252,6 +1253,8 @@ private:
return; return;
if (tryMergeTokens(JSShiftEqual)) if (tryMergeTokens(JSShiftEqual))
return; return;
if (tryMergeTokens(JSRightArrow))
return;
} }
} }
......
...@@ -77,6 +77,8 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) { ...@@ -77,6 +77,8 @@ TEST_F(FormatTestJS, UnderstandsJavaScriptOperators) {
" bbbbbb :\n" " bbbbbb :\n"
" ccc;", " ccc;",
getGoogleJSStyleWithColumns(20)); getGoogleJSStyleWithColumns(20));
verifyFormat("var b = a.map((x) => x + 1);");
} }
TEST_F(FormatTestJS, SpacesInContainerLiterals) { TEST_F(FormatTestJS, SpacesInContainerLiterals) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment