Browse Source

[Refactoring] Add Script.InsertAfter().

newNRvisualizers
Simon Lindgren 14 years ago
parent
commit
a4d5b7a770
  1. 12
      ICSharpCode.NRefactory.CSharp/Refactoring/Script.cs

12
ICSharpCode.NRefactory.CSharp/Refactoring/Script.cs

@ -153,6 +153,18 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring @@ -153,6 +153,18 @@ namespace ICSharpCode.NRefactory.CSharp.Refactoring
output.RegisterTrackedSegments(this, startOffset);
}
public void InsertAfter(AstNode node, AstNode insertNode)
{
var indentOffset = GetCurrentOffset(new TextLocation(node.StartLocation.Line, 1));
var output = OutputNode (GetIndentLevelAt (indentOffset), insertNode);
string text = output.Text;
if (!(insertNode is Expression || insertNode is AstType))
text = Options.EolMarker + text;
var insertOffset = GetCurrentOffset(node.EndLocation);
InsertText(insertOffset, text);
output.RegisterTrackedSegments(this, insertOffset);
}
public void AddTo(BlockStatement bodyStatement, AstNode insertNode)
{
var startOffset = GetCurrentOffset(bodyStatement.LBraceToken.EndLocation);

Loading…
Cancel
Save