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