From 8db1fe252f6539e9cde8c9fb5f59aa60e4089d8f Mon Sep 17 00:00:00 2001 From: Daniel Grunwald Date: Mon, 14 Feb 2011 16:53:08 +0100 Subject: [PATCH] Enforce space in output visitor when printing "ptr & &v". --- .../CSharp/OutputVisitor/OutputVisitor.cs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs b/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs index 62b70b2f9a..bcdbd894db 100644 --- a/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs +++ b/ICSharpCode.NRefactory/CSharp/OutputVisitor/OutputVisitor.cs @@ -35,6 +35,7 @@ namespace ICSharpCode.NRefactory.CSharp KeywordOrIdentifier, Plus, Minus, + Ampersand, QuestionMark, Division } @@ -221,10 +222,12 @@ namespace ICSharpCode.NRefactory.CSharp // Avoid that two +, - or ? tokens are combined into a ++, -- or ?? token. // Note that we don't need to handle tokens like = because there's no valid // C# program that contains the single token twice in a row. - // (for + and -, this can happen with unary operators; - // and for ?, this can happen in "a is int? ? b : c" or "a as int? ?? 0") + // (for +, - and &, this can happen with unary operators; + // for ?, this can happen in "a is int? ? b : c" or "a as int? ?? 0"; + // and for /, this can happen with "1/ *ptr" or "1/ //comment".) if (lastWritten == LastWritten.Plus && token[0] == '+' || lastWritten == LastWritten.Minus && token[0] == '-' + || lastWritten == LastWritten.Ampersand && token[0] == '&' || lastWritten == LastWritten.QuestionMark && token[0] == '?' || lastWritten == LastWritten.Division && token[0] == '*') { @@ -235,6 +238,8 @@ namespace ICSharpCode.NRefactory.CSharp lastWritten = LastWritten.Plus; else if (token == "-") lastWritten = LastWritten.Minus; + else if (token == "&") + lastWritten = LastWritten.Ampersand; else if (token == "?") lastWritten = LastWritten.QuestionMark; else if (token == "/")