mirror of
https://github.com/dlang-community/dfmt.git
synced 2025-04-25 21:00:03 +03:00
Fix #209
This commit is contained in:
parent
382258eb97
commit
bab1a5f592
4 changed files with 80 additions and 5 deletions
|
@ -431,6 +431,11 @@ private:
|
|||
}
|
||||
|
||||
void formatLeftParenOrBracket()
|
||||
in
|
||||
{
|
||||
assert(currentIs(tok!"(") || currentIs(tok!"["));
|
||||
}
|
||||
body
|
||||
{
|
||||
immutable p = tokens[index].type;
|
||||
regenLineBreakHintsIfNecessary(index);
|
||||
|
@ -464,15 +469,18 @@ private:
|
|||
}
|
||||
|
||||
void formatRightParen()
|
||||
in
|
||||
{
|
||||
assert(currentIs(tok!")"));
|
||||
}
|
||||
body
|
||||
{
|
||||
parenDepth--;
|
||||
if (parenDepth == 0)
|
||||
indents.popWrapIndents();
|
||||
if (parenDepth == 0 && (currentIs(tok!"out") || currentIs(tok!"body")))
|
||||
{
|
||||
|
||||
if (parenDepth == 0 && (peekIs(tok!"in") || peekIs(tok!"out") || peekIs(tok!"body")))
|
||||
writeToken();
|
||||
newline();
|
||||
}
|
||||
else if (peekIsLiteralOrIdent() || peekIsBasicType())
|
||||
{
|
||||
writeToken();
|
||||
|
@ -770,7 +778,9 @@ private:
|
|||
if (!currentIs(tok!"{") && !currentIs(tok!";"))
|
||||
write(" ");
|
||||
}
|
||||
else if (!currentIs(tok!"{") && !currentIs(tok!";"))
|
||||
else if (!currentIs(tok!"{") && !currentIs(tok!";")
|
||||
&& !currentIs(tok!"in") && !currentIs(tok!"out")
|
||||
&& !currentIs(tok!"body"))
|
||||
newline();
|
||||
}
|
||||
|
||||
|
@ -835,7 +845,10 @@ private:
|
|||
case tok!"in":
|
||||
immutable isContract = astInformation.contractLocations.canFindIndex(current.index);
|
||||
if (isContract)
|
||||
{
|
||||
indents.popTempIndents();
|
||||
newline();
|
||||
}
|
||||
else if (!peekBackIsOneOf(false, tok!"(", tok!",", tok!"!"))
|
||||
write(" ");
|
||||
writeToken();
|
||||
|
|
23
tests/allman/issue0209.d.ref
Normal file
23
tests/allman/issue0209.d.ref
Normal file
|
@ -0,0 +1,23 @@
|
|||
unittest
|
||||
{
|
||||
{
|
||||
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(
|
||||
const Vector!(T) x) const if (op == "*")
|
||||
in
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(
|
||||
const Vector!(T) x) const if (op == "*")
|
||||
in
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
21
tests/issue0209.d
Normal file
21
tests/issue0209.d
Normal file
|
@ -0,0 +1,21 @@
|
|||
unittest
|
||||
{
|
||||
{
|
||||
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(const Vector!(T) x) const if (op == "*")
|
||||
in
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(const Vector!(T) x) const if (op == "*")
|
||||
in
|
||||
{
|
||||
}
|
||||
body
|
||||
{
|
||||
}
|
18
tests/otbs/issue0209.d.ref
Normal file
18
tests/otbs/issue0209.d.ref
Normal file
|
@ -0,0 +1,18 @@
|
|||
unittest {
|
||||
{
|
||||
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(
|
||||
const Vector!(T) x) const if (op == "*")
|
||||
in {
|
||||
}
|
||||
body {
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
public Vector!(T) opBinary(string op, string file = __FILE__, size_t line = __LINE__)(
|
||||
const Vector!(T) x) const if (op == "*")
|
||||
in {
|
||||
}
|
||||
body {
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue