[PATCH] D23761: clang-format: [JS] supports casts to types starting with punctuation ("{[(").
Martin Probst via cfe-commits
cfe-commits at lists.llvm.org
Mon Aug 22 04:23:02 PDT 2016
mprobst updated this revision to Diff 68844.
mprobst added a comment.
- drop accidentally included template string patch from this diff.
https://reviews.llvm.org/D23761
Files:
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp
Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1219,6 +1219,9 @@
" 2\n"
"];");
verifyFormat("var x = [{x: 1} as type];");
+ verifyFormat("x = x as [a, b];");
+ verifyFormat("x = x as {a: string};");
+ verifyFormat("x = x as (string);");
}
TEST_F(FormatTestJS, TypeArguments) {
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2121,6 +2121,9 @@
Keywords.kw_of, tok::kw_const) &&
(!Left.Previous || !Left.Previous->is(tok::period)))
return true;
+ if (Left.is(Keywords.kw_as) &&
+ Right.isOneOf(tok::l_square, tok::l_brace, tok::l_paren))
+ return true;
if (Left.is(tok::kw_default) && Left.Previous &&
Left.Previous->is(tok::kw_export))
return true;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D23761.68844.patch
Type: text/x-patch
Size: 1036 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20160822/7a6c95a5/attachment-0001.bin>
More information about the cfe-commits
mailing list