CSharpOutline.TextRegion.ParseBuffer C# (CSharp) Method

ParseBuffer() public static method

parses buffer
public static ParseBuffer ( SnapshotParser parser, TextRegion parent ) : TextRegion
parser SnapshotParser
parent TextRegion parent region or null
return TextRegion
        public static TextRegion ParseBuffer(SnapshotParser parser, TextRegion parent)
        {
            for (; !parser.AtEnd(); parser.MoveNext())
            {
                TextRegion r = TextRegion.TryCreateRegion(parser);

                if (r != null)
                {
                    parser.MoveNext();
                    //found the start of the region
                    if (!r.Complete)
                    {
                        //searching for child regions
                        while (TextRegion.ParseBuffer(parser, r) != null) ;
                        //found everything
                        r.ExtendStartPoint();
                    }
                    //adding to children or merging with last child
                    r.Parent = parent;
                    parent.Children.Add(r);
                    return r;
                }
                //found parent's end - terminating parsing
                if (parent.TryComplete(parser))
                {
                    parser.MoveNext();
                    return null;
                }
            }
            return null;
        }

Usage Example

Beispiel #1
0
        /// <summary>
        /// parses buffer
        /// </summary>
        /// <param name="parser"></param>
        /// <param name="parent">parent region or null</param>
        /// <returns>a region with its children or null</returns>
        public static TextRegion ParseBuffer(SnapshotParser parser, TextRegion parent)
        {
            for (; !parser.AtEnd(); parser.MoveNext())
            {
                TextRegion r = TextRegion.TryCreateRegion(parser);

                if (r != null)
                {
                    parser.MoveNext();
                    //found the start of the region
                    if (!r.Complete)
                    {
                        //searching for child regions
                        while (TextRegion.ParseBuffer(parser, r) != null)
                        {
                            ;
                        }
                        //found everything
                        r.ExtendStartPoint();
                    }
                    //adding to children or merging with last child
                    r.Parent = parent;
                    parent.Children.Add(r);
                    return(r);
                }
                //found parent's end - terminating parsing
                if (parent.TryComplete(parser))
                {
                    parser.MoveNext();
                    return(null);
                }
            }
            return(null);
        }
All Usage Examples Of CSharpOutline.TextRegion::ParseBuffer