Siegfried Pammer 15 years ago
parent
commit
b83553d64c
  1. 9
      src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

9
src/Libraries/NRefactory/Project/Src/PrettyPrinter/CSharp/CSharpOutputVisitor.cs

@ -1956,12 +1956,15 @@ namespace ICSharpCode.NRefactory.PrettyPrinter
else else
TrackVisit(forNextStatement.LoopVariableExpression, data); TrackVisit(forNextStatement.LoopVariableExpression, data);
outputFormatter.Space(); outputFormatter.Space();
PrimitiveExpression pe = forNextStatement.Step as PrimitiveExpression; Expression stepExpr = forNextStatement.Step;
while (stepExpr is ParenthesizedExpression)
stepExpr = ((ParenthesizedExpression)stepExpr).Expression;
PrimitiveExpression pe = stepExpr as PrimitiveExpression;
if ((pe == null || !(pe.Value is int) || ((int)pe.Value) >= 0) if ((pe == null || !(pe.Value is int) || ((int)pe.Value) >= 0)
&& !(forNextStatement.Step is UnaryOperatorExpression)) && !(stepExpr is UnaryOperatorExpression))
outputFormatter.PrintToken(Tokens.LessEqual); outputFormatter.PrintToken(Tokens.LessEqual);
else { else {
if (forNextStatement.Step is UnaryOperatorExpression && ((UnaryOperatorExpression)forNextStatement.Step).Op == UnaryOperatorType.Plus) if (stepExpr is UnaryOperatorExpression && ((UnaryOperatorExpression)stepExpr).Op == UnaryOperatorType.Plus)
outputFormatter.PrintToken(Tokens.LessEqual); outputFormatter.PrintToken(Tokens.LessEqual);
else else
outputFormatter.PrintToken(Tokens.GreaterEqual); outputFormatter.PrintToken(Tokens.GreaterEqual);

Loading…
Cancel
Save