This commit is contained in:
Hackerpilot 2015-03-08 17:28:03 -07:00
parent 7952562efc
commit 95cfcc5b0a
3 changed files with 33 additions and 20 deletions

View File

@ -333,6 +333,7 @@ private:
writeToken(); writeToken();
writeParens(true); writeParens(true);
break; break;
case tok!"in":
case tok!"is": case tok!"is":
writeToken(); writeToken();
if (!currentIs(tok!"(")) if (!currentIs(tok!"("))
@ -772,34 +773,27 @@ private:
} }
else if (current.type == tok!")") else if (current.type == tok!")")
{ {
if (peekIsLiteralOrIdent() || peekIsBasicType())
{
writeToken();
if (space_afterwards)
write(" ");
}
else if (index + 1 < tokens.length)
{
if (tokens[index + 1].type == tok!"in"
|| tokens[index + 1].type == tok!"out"
|| tokens[index + 1].type == tok!"body")
{
writeToken();
newline();
}
else if (isKeyword(tokens[index + 1].type)
|| tokens[index + 1].type == tok!"@")
{
writeToken();
if (space_afterwards)
write(" ");
}
else
writeToken();
}
else
writeToken();
depth--; depth--;
if (depth == 0 && (peekIs(tok!"in") || peekIs(tok!"out")
|| peekIs(tok!"body")))
{
writeToken(); // )
newline();
writeToken(); // in/out/body
}
else if (peekIsLiteralOrIdent() || peekIsBasicType() || peekIsKeyword())
{
writeToken();
if (space_afterwards || depth > 0)
write(" ");
}
else if ((peekIsKeyword() || peekIs(tok!"@")) && space_afterwards)
{
writeToken();
write(" ");
}
else
writeToken();
} }
else else
formatStep(); formatStep();
@ -810,6 +804,11 @@ private:
linebreakHints = []; linebreakHints = [];
} }
bool peekIsKeyword()
{
return index + 1 < tokens.length && isKeyword(tokens[index + 1].type);
}
bool peekIsBasicType() bool peekIsBasicType()
{ {
return index + 1 < tokens.length && isBasicType(tokens[index + 1].type); return index + 1 < tokens.length && isBasicType(tokens[index + 1].type);

5
tests/issue0065.d Normal file
View File

@ -0,0 +1,5 @@
void main(string[] args)
{
if ((*tempdecl.parameters) [i].isTemplateThisParameter()is null){}
if (a()in b||a()is b){}
}

9
tests/issue0065.d.ref Normal file
View File

@ -0,0 +1,9 @@
void main(string[] args)
{
if ((*tempdecl.parameters)[i].isTemplateThisParameter() is null)
{
}
if (a() in b || a() is b)
{
}
}