[PATCH] D36147: clang-format: [JS] handle union types in arrow functions.
Martin Probst via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Aug 1 10:21:30 PDT 2017
This revision was automatically updated to reflect the committed changes.
Closed by commit rL309707: clang-format: [JS] handle union types in arrow functions. (authored by mprobst).
Repository:
rL LLVM
https://reviews.llvm.org/D36147
Files:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Index: cfe/trunk/lib/Format/TokenAnnotator.cpp
===================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp
@@ -533,6 +533,7 @@
Contexts.back().ContextKind == tok::l_square || // array type
(Contexts.size() == 1 &&
Line.MustBeDeclaration)) { // method/property declaration
+ Contexts.back().IsExpression = false;
Tok->Type = TT_JsTypeColon;
break;
}
Index: cfe/trunk/unittests/Format/FormatTestJS.cpp
===================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp
@@ -988,6 +988,9 @@
" .doSomethingElse(\n"
" // break\n"
" );");
+ verifyFormat("const f = (x: string|null): string|null => {\n"
+ " return x;\n"
+ "}\n");
}
TEST_F(FormatTestJS, ReturnStatements) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D36147.109152.patch
Type: text/x-patch
Size: 1034 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20170801/dd14c6ff/attachment.bin>
More information about the cfe-commits
mailing list