r257162 - clang-format: [JS] Prefer wrapping before the TypeScript return type
Daniel Jasper via cfe-commits
cfe-commits at lists.llvm.org
Fri Jan 8 02:51:24 PST 2016
Author: djasper
Date: Fri Jan 8 04:51:24 2016
New Revision: 257162
URL: http://llvm.org/viewvc/llvm-project?rev=257162&view=rev
Log:
clang-format: [JS] Prefer wrapping before the TypeScript return type
over wrapping before parameters.
Before:
function someFunc(
args: string[]): {longReturnValue: string[]} {}
After:
function someFunc(args: string[]):
{longReturnValue: string[]} {}
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=257162&r1=257161&r2=257162&view=diff
==============================================================================
--- cfe/trunk/lib/Format/TokenAnnotator.cpp (original)
+++ cfe/trunk/lib/Format/TokenAnnotator.cpp Fri Jan 8 04:51:24 2016
@@ -1725,7 +1725,7 @@ unsigned TokenAnnotator::splitPenalty(co
if (Right.is(Keywords.kw_function) && Left.isNot(tok::comma))
return 100;
if (Left.is(TT_JsTypeColon))
- return 100;
+ return 35;
}
if (Left.is(tok::comma) || (Right.is(tok::identifier) && Right.Next &&
Modified: cfe/trunk/unittests/Format/FormatTestJS.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/unittests/Format/FormatTestJS.cpp?rev=257162&r1=257161&r2=257162&view=diff
==============================================================================
--- cfe/trunk/unittests/Format/FormatTestJS.cpp (original)
+++ cfe/trunk/unittests/Format/FormatTestJS.cpp Fri Jan 8 04:51:24 2016
@@ -740,6 +740,9 @@ TEST_F(FormatTestJS, TypeAnnotations) {
verifyFormat("var x: P<string, (a: number) => string>;");
verifyFormat("var x = {y: function(): z { return 1; }};");
verifyFormat("var x = {y: function(): {a: number} { return 1; }};");
+ verifyFormat("function someFunc(args: string[]):\n"
+ " {longReturnValue: string[]} {}",
+ getGoogleJSStyleWithColumns(60));
}
TEST_F(FormatTestJS, ClassDeclarations) {
More information about the cfe-commits
mailing list