Microsoft.R.Core.AST.AstNode.GetPositionNode C# (CSharp) Method

GetPositionNode() public method

Determines position type and the enclosing node for a given position in the document text.
public GetPositionNode ( int position, IAstNode &node ) : PositionType
position int Position in the document text
node IAstNode Node that contains position
return PositionType
        public virtual PositionType GetPositionNode(int position, out IAstNode node) {
            node = null;

            if (!this.Contains(position)) {
                return PositionType.Undefined;
            }

            for (int i = 0; i < this.Children.Count; i++) {
                var child = Children[i];

                if (position < child.Start)
                    break;

                if (child.Contains(position)) {
                    return child.GetPositionNode(position, out node);
                }
            }

            node = this;
            return node is TokenNode ? PositionType.Token : PositionType.Node;
        }