No trailing space after for,foreach,etc

This commit is contained in:
Andreas Zwinkau 2015-01-16 20:46:06 +01:00
parent 9284f1afb6
commit feb75b4d3b
1 changed files with 6 additions and 5 deletions

View File

@ -215,7 +215,7 @@ private:
currentLineLength += currentTokenLength() + 1; currentLineLength += currentTokenLength() + 1;
writeToken(); writeToken();
write(" "); write(" ");
writeParens(); writeParens(false);
if (current.type != tok!"{" && current.type != tok!";") if (current.type != tok!"{" && current.type != tok!";")
{ {
pushIndent(); pushIndent();
@ -286,7 +286,7 @@ private:
} }
goto binary; goto binary;
case tok!"(": case tok!"(":
writeParens(); writeParens(true);
break; break;
case tok!":": case tok!":":
if (!assumeSorted(astInformation.ternaryColonLocations) if (!assumeSorted(astInformation.ternaryColonLocations)
@ -488,7 +488,7 @@ private:
popIndent(); popIndent();
} }
void writeParens() void writeParens(bool space_afterwards)
in in
{ {
assert (current.type == tok!"(", str(current.type)); assert (current.type == tok!"(", str(current.type));
@ -518,7 +518,8 @@ private:
&& isKeyword(tokens[index + 1].type))) && isKeyword(tokens[index + 1].type)))
{ {
writeToken(); writeToken();
write(" "); if (space_afterwards)
write(" ");
} }
else else
writeToken(); writeToken();
@ -542,7 +543,7 @@ private:
immutable l = indentLevel; immutable l = indentLevel;
writeToken(); // switch writeToken(); // switch
write(" "); write(" ");
writeParens(); writeParens(true);
if (current.type != tok!"{") if (current.type != tok!"{")
return; return;
if (config.braceStyle == BraceStyle.otbs) if (config.braceStyle == BraceStyle.otbs)