r241339 - clang-format: [JS] Allow line breaks after TypeScript type colons.
Daniel Jasper
djasper at google.com
Fri Jul 3 03:37:23 PDT 2015
Author: djasper
Date: Fri Jul 3 05:37:23 2015
New Revision: 241339
URL: http://llvm.org/viewvc/llvm-project?rev=241339&view=rev
Log:
clang-format: [JS] Allow line breaks after TypeScript type colons.
Modified:
cfe/trunk/lib/Format/TokenAnnotator.cpp
cfe/trunk/unittests/Format/FormatTestJS.cpp
Modified: cfe/trunk/lib/Format/TokenAnnotator.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Format/TokenAnnotator.cpp?rev=241339&r1=241338&r2=241339&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jul 3 05:37:23 2015
@@ -2136,6 +2136,8 @@ bool TokenAnnotator::canBreakBefore(cons
} else if (Style.Language == FormatStyle::LK_JavaScript) {
if (Left.is(TT_JsFatArrow) && Right.is(tok::l_brace))
return false;
+ if (Left.is(TT_JsTypeColon))
+ return true;
}
if (Left.is(tok::at))
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=241339&r1=241338&r2=241339&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jul 3 05:37:23 2015
@@ -883,6 +883,8 @@ TEST_F(FormatTestJS, TypeArguments) {
verifyFormat("class C extends D<E> implements F<G>, H<I> {}");
verifyFormat("function f(a: List<any> = null) {}");
verifyFormat("function f(): List<any> {}");
+ verifyFormat("function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa():\n"
+ " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {}");
}
TEST_F(FormatTestJS, OptionalTypes) {
More information about the cfe-commits
mailing list