dfmt
dfmt copied to clipboard
Subexpressions of a split expression should start at new lines
Input:
int longFunctionName(int[] ar...)
{
return ar[0];
}
int f(int x)
{
return x == 1
? longFunctionName(x, longFunctionName(x, x))
: longFunctionName(x, longFunctionName(x, x));
}
int g(int x)
{
return longFunctionName(
123,
longFunctionName(x, 1),
longFunctionName(x, 2),
longFunctionName(x, 3));
}
Output:
int longFunctionName(int[] ar...)
{
return ar[0];
}
int f(int x)
{
return x == 1 ? longFunctionName(x, longFunctionName(x, x)) : longFunctionName(x,
longFunctionName(x, x));
}
int g(int x)
{
return longFunctionName(123, longFunctionName(x, 1), longFunctionName(x,
2), longFunctionName(x, 3));
}
In both cases, the code was already well formatted. So I would prefer that "input" and "output" be reversed here. When an expression needs to be split into multiple lines, I would prefer that each subexpression of the original expression start at its own line. Instead, the formatter puts as much as possible on the first line, splitting at some deeply nested token.