/// <summary> /// Gets the first occurrance of a node type in the AST. /// </summary> /// <param name="nodeType">The node type to look for.</param> /// <returns>A <see cref="SyntaxNode"/>.</returns> public SyntaxNode LocateFirst(Type nodeType) { ValidateInputType(nodeType); List<SyntaxNode> nodes = new List<SyntaxNode>(); var astExecutor = new ASTWalkerNodeTypeOperationExecutor(this.Root, nodeType, (node) => nodes.Add(node)); astExecutor.Start(); return nodes.Count > 0 ? nodes[0] : null; }
/// <summary> /// Gets all occurrances of a node type in the AST. /// </summary> /// <param name="nodeType">The node type to look for.</param> /// <returns>A <see cref="SyntaxNode"/>.</returns> public IEnumerable<SyntaxNode> LocateAll(Type nodeType) { ValidateInputType(nodeType); List<SyntaxNode> nodes = new List<SyntaxNode>(); var astExecutor = new ASTWalkerNodeTypeOperationExecutor(this.Root, nodeType, (node) => nodes.Add(node)); astExecutor.Start(); return nodes.ToArray(); }