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
{ {
} }
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> (); Stack<AstNode> nodeStack = new Stack<AstNode> ();
nodeStack.Push(this); nodeStack.Push(this);
while (nodeStack.Count > 0) { while (nodeStack.Count > 0) {
var curNode = nodeStack.Pop(); var curNode = nodeStack.Pop();
if (curNode is TypeDeclaration) { if (curNode is TypeDeclaration || curNode is DelegateDeclaration) {
yield return (TypeDeclaration)curNode; yield return (EntityDeclaration)curNode;
} }
foreach (var child in curNode.Children) { foreach (var child in curNode.Children) {
if (!(child is Statement || child is Expression) && if (!(child is Statement || child is Expression) &&
@ -121,6 +127,7 @@ namespace ICSharpCode.NRefactory.CSharp
} }
} }
} }
protected internal override bool DoMatch(AstNode other, PatternMatching.Match match) protected internal override bool DoMatch(AstNode other, PatternMatching.Match match)
{ {

Loading…
Cancel
Save