Browse Source

Add NextStatement/PreviousStatement properties.

pull/100/head
Daniel Grunwald 15 years ago
parent
commit
f537fafdeb
  1. 32
      NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs

32
NRefactory/ICSharpCode.NRefactory/CSharp/Ast/Statements/Statement.cs

@ -38,6 +38,38 @@ namespace ICSharpCode.NRefactory.CSharp
} }
#endregion #endregion
/// <summary>
/// Gets the previous statement within the current block.
/// This is usually equivalent to <see cref="PrevSibling"/>, but will skip any non-statements (e.g. comments)
/// </summary>
public Statement PreviousStatement {
get {
AstNode node = this;
while ((node = node.PrevSibling) != null) {
Statement stmt = node as Statement;
if (stmt != null)
return stmt;
}
return null;
}
}
/// <summary>
/// Gets the next statement within the current block.
/// This is usually equivalent to <see cref="NextSibling"/>, but will skip any non-statements (e.g. comments)
/// </summary>
public Statement NextStatement {
get {
AstNode node = this;
while ((node = node.NextSibling) != null) {
Statement stmt = node as Statement;
if (stmt != null)
return stmt;
}
return null;
}
}
public new Statement Clone() public new Statement Clone()
{ {
return (Statement)base.Clone(); return (Statement)base.Clone();

Loading…
Cancel
Save