Browse Source

Fixed formatting unit tests on windows.

newNRvisualizers
Mike Krüger 14 years ago
parent
commit
38b35b70fa
  1. 2
      ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs
  2. 2
      ICSharpCode.NRefactory.CSharp/Refactoring/TextReplaceAction.cs
  3. 6
      ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs

2
ICSharpCode.NRefactory.CSharp/Formatter/AstFormattingVisitor.cs

@ -995,7 +995,7 @@ namespace ICSharpCode.NRefactory.CSharp
return; return;
} }
} }
//Console.WriteLine ("offset={0}, removedChars={1}, insertedText={2}", offset, removedChars, insertedText == null ? "<null>" : insertedText.Replace ("\n", "\\n").Replace ("\t", "\\t").Replace (" ", ".")); //Console.WriteLine ("offset={0}, removedChars={1}, insertedText={2}", offset, removedChars, insertedText == null ? "<null>" : insertedText.Replace ("\n", "\\n").Replace ("\r", "\\r").Replace ("\t", "\\t").Replace (" ", "."));
//Console.WriteLine (Environment.StackTrace); //Console.WriteLine (Environment.StackTrace);
changes.Add (factory.CreateTextReplaceAction (offset, removedChars, insertedText)); changes.Add (factory.CreateTextReplaceAction (offset, removedChars, insertedText));

2
ICSharpCode.NRefactory.CSharp/Refactoring/TextReplaceAction.cs

@ -128,7 +128,7 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
/// </returns> /// </returns>
public override string ToString () public override string ToString ()
{ {
return string.Format ("[TextReplaceAction: Offset={0}, RemovedChars={1}, InsertedText={2}]", Offset, RemovedChars, InsertedText == null ? "<null>" : InsertedText.Replace ("\t", "\\t").Replace ("\n", "\\n")); return string.Format ("[TextReplaceAction: Offset={0}, RemovedChars={1}, InsertedText={2}]", Offset, RemovedChars, InsertedText == null ? "<null>" : InsertedText.Replace ("\t", "\\t").Replace ("\n", "\\n").Replace ("\r", "\\r"));
} }
} }
} }

6
ICSharpCode.NRefactory.Tests/FormattingTests/TextEditorTestAdapter.cs

@ -37,7 +37,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
changes.Sort ((x, y) => y.Offset.CompareTo (x.Offset)); changes.Sort ((x, y) => y.Offset.CompareTo (x.Offset));
StringBuilder b = new StringBuilder(text); StringBuilder b = new StringBuilder(text);
foreach (var change in changes) { foreach (var change in changes) {
// Console.WriteLine ("---- apply:" + change); //Console.WriteLine ("---- apply:" + change);
// Console.WriteLine (adapter.Text); // Console.WriteLine (adapter.Text);
if (change.Offset > b.Length) if (change.Offset > b.Length)
continue; continue;
@ -53,7 +53,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
{ {
var adapter = new ReadOnlyDocument (input); var adapter = new ReadOnlyDocument (input);
var visitor = new AstFormattingVisitor (policy, adapter, factory); var visitor = new AstFormattingVisitor (policy, adapter, factory);
visitor.EolMarker = "\n";
var compilationUnit = new CSharpParser ().Parse (new StringReader (input), "test.cs"); var compilationUnit = new CSharpParser ().Parse (new StringReader (input), "test.cs");
compilationUnit.AcceptVisitor (visitor, null); compilationUnit.AcceptVisitor (visitor, null);
@ -73,7 +73,7 @@ namespace ICSharpCode.NRefactory.FormattingTests
protected static void Continue (CSharpFormattingOptions policy, IDocument document, string expectedOutput) protected static void Continue (CSharpFormattingOptions policy, IDocument document, string expectedOutput)
{ {
var visitior = new AstFormattingVisitor (policy, document, factory); var visitior = new AstFormattingVisitor (policy, document, factory);
visitior.EolMarker = "\n";
var compilationUnit = new CSharpParser ().Parse (new StringReader (document.Text), "test.cs"); var compilationUnit = new CSharpParser ().Parse (new StringReader (document.Text), "test.cs");
compilationUnit.AcceptVisitor (visitior, null); compilationUnit.AcceptVisitor (visitior, null);
string newText = ApplyChanges (document.Text, visitior.Changes); string newText = ApplyChanges (document.Text, visitior.Changes);

Loading…
Cancel
Save