From 73e63ddca17b2ddb6cb709ca244de39d2ca261d6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20Kr=C3=BCger?= Date: Sat, 25 Feb 2012 08:20:45 +0100 Subject: [PATCH] Added GetText function to AstNode. --- ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs index 78e717b490..4da21873e3 100644 --- a/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs +++ b/ICSharpCode.NRefactory.CSharp/Ast/AstNode.cs @@ -642,6 +642,21 @@ namespace ICSharpCode.NRefactory.CSharp } } + /// + /// Gets the node as formatted C# output. + /// + /// + /// Formatting options. + /// + public string GetText (CSharpFormattingOptions formattingOptions = null) + { + if (IsNull) + return ""; + var w = new StringWriter (); + AcceptVisitor (new CSharpOutputVisitor (w, formattingOptions ?? new CSharpFormattingOptions ()), null); + return w.ToString (); + } + public bool Contains (int line, int column) { return Contains (new TextLocation (line, column));