Browse Source

fixed inconsistency with \r and \n in the code generation and insertion code.

git-svn-id: svn://svn.sharpdevelop.net/sharpdevelop/branches/3.0@3545 1ccf3a8d-04fe-1044-b7c0-cef0b8235c61
shortcuts
Siegfried Pammer 18 years ago
parent
commit
706c26290e
  1. 20
      src/AddIns/Misc/SharpRefactoring/Src/MethodExtractorBase.cs

20
src/AddIns/Misc/SharpRefactoring/Src/MethodExtractorBase.cs

@ -4,11 +4,12 @@
// <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/> // <owner name="Siegfried Pammer" email="sie_pam@gmx.at"/>
// <version>$Revision: 3287 $</version> // <version>$Revision: 3287 $</version>
// </file> // </file>
using ICSharpCode.TextEditor;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
using ICSharpCode.Core; using ICSharpCode.Core;
using ICSharpCode.NRefactory; using ICSharpCode.NRefactory;
using ICSharpCode.NRefactory.Ast; using ICSharpCode.NRefactory.Ast;
@ -16,6 +17,7 @@ using ICSharpCode.NRefactory.PrettyPrinter;
using ICSharpCode.NRefactory.Visitors; using ICSharpCode.NRefactory.Visitors;
using ICSharpCode.SharpDevelop; using ICSharpCode.SharpDevelop;
using ICSharpCode.SharpDevelop.Project; using ICSharpCode.SharpDevelop.Project;
using ICSharpCode.TextEditor;
using ICSharpCode.TextEditor.Document; using ICSharpCode.TextEditor.Document;
using SharpRefactoring.Visitors; using SharpRefactoring.Visitors;
using Dom = ICSharpCode.SharpDevelop.Dom; using Dom = ICSharpCode.SharpDevelop.Dom;
@ -125,22 +127,24 @@ namespace SharpRefactoring
builder.AppendLine(GenerateCode(v, false)); builder.AppendLine(GenerateCode(v, false));
} }
this.currentDocument.Replace(this.currentSelection.Offset, this.currentSelection.Length, /*builder.ToString() + "\n" +*/ call); this.currentDocument.Replace(this.currentSelection.Offset, this.currentSelection.Length, builder.ToString() + "\r\n" + call);
} }
public void InsertAfterCurrentMethod() public void InsertAfterCurrentMethod()
{ {
using (SpecialNodesInserter.Install(this.specialsList, this.output)) { using (SpecialNodesInserter.Install(this.specialsList, this.output)) {
string code = "\n\n" + GenerateCode(this.extractedMethod, true); string code = "\r\n\r\n" + GenerateCode(this.extractedMethod, true);
code = code.TrimEnd('\n', ' ', '\t'); code = code.TrimEnd('\r', '\n', ' ', '\t');
Dom.IMember p = GetParentMember(this.textEditor, this.currentSelection.StartPosition.Line, this.currentSelection.StartPosition.Column); Dom.IMember p = GetParentMember(this.textEditor, this.currentSelection.StartPosition.Line, this.currentSelection.StartPosition.Column);
TextLocation loc = new ICSharpCode.TextEditor.TextLocation(
p.BodyRegion.EndColumn - 1, p.BodyRegion.EndLine - 1);
int offset = textEditor.Document.PositionToOffset(loc);
textEditor.Document.Insert(textEditor.Document.PositionToOffset( textEditor.Document.Insert(offset, code);
new ICSharpCode.TextEditor.TextLocation(
p.BodyRegion.EndColumn - 1, p.BodyRegion.EndLine - 1)
), code);
} }
} }

Loading…
Cancel
Save