[PATCH] D48030: clang-format: [JS] strict prop init annotation.
Martin Probst via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Mon Jun 11 08:46:48 PDT 2018
mprobst updated this revision to Diff 150770.
mprobst added a comment.
fix typo in test
Repository:
rC Clang
https://reviews.llvm.org/D48030
Files:
lib/Format/TokenAnnotator.cpp
unittests/Format/FormatTestJS.cpp
Index: unittests/Format/FormatTestJS.cpp
===================================================================
--- unittests/Format/FormatTestJS.cpp
+++ unittests/Format/FormatTestJS.cpp
@@ -1540,6 +1540,15 @@
"}");
}
+TEST_F(FormatTestJS, StrictPropInitWrap) {
+ const FormatStyle &Style = getGoogleJSStyleWithColumns(22);
+ verifyFormat("class X {\n"
+ " strictPropInitField!:\n"
+ " string;\n"
+ "}",
+ Style);
+}
+
TEST_F(FormatTestJS, InterfaceDeclarations) {
verifyFormat("interface I {\n"
" x: string;\n"
Index: lib/Format/TokenAnnotator.cpp
===================================================================
--- lib/Format/TokenAnnotator.cpp
+++ lib/Format/TokenAnnotator.cpp
@@ -2981,7 +2981,7 @@
// We deal with this case later by detecting an entry
// following a closing paren of this submessage.
}
-
+
// If this is an entry immediately following a submessage, it will be
// preceded by a closing paren of that submessage, like in:
// left---. .---right
@@ -3027,6 +3027,9 @@
return false;
if (Left.is(TT_JsTypeColon))
return true;
+ // Don't wrap between ":" and "!" of a strict prop init ("field!: type;").
+ if (Left.is(tok::exclaim) && Right.is(tok::colon))
+ return false;
if (Right.is(Keywords.kw_is))
return false;
if (Left.is(Keywords.kw_in))
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D48030.150770.patch
Type: text/x-patch
Size: 1457 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20180611/dab8d168/attachment.bin>
More information about the cfe-commits
mailing list