From: Daniel Jasper Date: Fri, 3 Jul 2015 10:37:23 +0000 (+0000) Subject: clang-format: [JS] Allow line breaks after TypeScript type colons. X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b3632d4efa2361f488a05005b9085f7083fc72a9;p=clang clang-format: [JS] Allow line breaks after TypeScript type colons. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241339 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Format/TokenAnnotator.cpp b/lib/Format/TokenAnnotator.cpp index 48dedeaef6..0e1f14ad05 100644 --- a/lib/Format/TokenAnnotator.cpp +++ b/lib/Format/TokenAnnotator.cpp @@ -2136,6 +2136,8 @@ bool TokenAnnotator::canBreakBefore(const AnnotatedLine &Line, } 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)) diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp index b3e0f68ac3..e6c12f4ce0 100644 --- a/unittests/Format/FormatTestJS.cpp +++ b/unittests/Format/FormatTestJS.cpp @@ -883,6 +883,8 @@ TEST_F(FormatTestJS, TypeArguments) { verifyFormat("class C extends D implements F, H {}"); verifyFormat("function f(a: List = null) {}"); verifyFormat("function f(): List {}"); + verifyFormat("function aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa():\n" + " bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb {}"); } TEST_F(FormatTestJS, OptionalTypes) {