Browse Source

[Ast] GetTypes now includes delegate declarations as well.

newNRvisualizers
mkrueger 14 years ago
parent
commit
1f78013258
  1. 13
      ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs

13
ICSharpCode.NRefactory.CSharp/Ast/SyntaxTree.cs

@ -105,14 +105,20 @@ namespace ICSharpCode.NRefactory.CSharp @@ -105,14 +105,20 @@ namespace ICSharpCode.NRefactory.CSharp
{
}
public IEnumerable<TypeDeclaration> GetTypes(bool includeInnerTypes = false)
/// <summary>
/// Gets all defined types in this syntax tree.
/// </summary>
/// <returns>
/// A list containing <see cref="TypeDeclaration"/> or <see cref="DelegateDeclaration"/> nodes.
/// </returns>
public IEnumerable<EntityDeclaration> GetTypes(bool includeInnerTypes = false)
{
Stack<AstNode> nodeStack = new Stack<AstNode> ();
nodeStack.Push(this);
while (nodeStack.Count > 0) {
var curNode = nodeStack.Pop();
if (curNode is TypeDeclaration) {
yield return (TypeDeclaration)curNode;
if (curNode is TypeDeclaration || curNode is DelegateDeclaration) {
yield return (EntityDeclaration)curNode;
}
foreach (var child in curNode.Children) {
if (!(child is Statement || child is Expression) &&
@ -122,6 +128,7 @@ namespace ICSharpCode.NRefactory.CSharp @@ -122,6 +128,7 @@ namespace ICSharpCode.NRefactory.CSharp
}
}
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{
SyntaxTree o = other as SyntaxTree;

Loading…
Cancel
Save