Split() public method

public Split ( LinkedListNode splitNode, bool after ) : ElementToken
splitNode LinkedListNode
after bool
return ElementToken
示例#1
0
        static ElementToken Split(ElementToken token, int index)
        {
            for (var node = token.Tokens.First; ; node = node.Next)
            {
                var r = node.Value;

                if (index == r.StartIndex)
                {
                    return(token.Split(node, false));
                }
                if (index < r.EndIndex)
                {
                    return(SplitNode(token, node, index, false));
                }
            }
        }
示例#2
0
        static ElementToken SplitBack(ElementToken token, int index)
        {
            for (var node = token.Tokens.Last; ; node = node.Previous)
            {
                var r = node.Value;

                if (index == r.EndIndex)
                {
                    return(token.Split(node, true));
                }
                if (index > r.StartIndex)
                {
                    return(SplitNode(token, node, index, true));
                }
            }
        }
示例#3
0
        static ElementToken SplitNode(ElementToken token, LinkedListNode <ParseToken> node, int index, bool back)
        {
            var curToken = node.Value;

            ParseToken newToken = null;

            if (curToken is TextToken)
            {
                // split text
                newToken = ((TextToken)curToken).Split(index);
            }
            else if (curToken is ElementToken)
            {
                newToken = back
                                                                                         ? SplitBack((ElementToken)curToken, index)
                                                                                         : Split((ElementToken)curToken, index);
            }

            // add new node after curNode
            token.Tokens.AddAfter(node, newToken);

            // split by node
            return(token.Split(node, true));
        }
示例#4
0
        static ElementToken SplitBack(ElementToken token, int index)
        {
            for (var node = token.Tokens.Last; ; node = node.Previous)
            {
                var r = node.Value;

                if (index == r.EndIndex) return token.Split(node, true);
                if (index > r.StartIndex) return SplitNode(token, node, index, true);
            }
        }
示例#5
0
        static ElementToken Split(ElementToken token, int index)
        {
            for (var node = token.Tokens.First; ; node = node.Next)
            {
                var r = node.Value;

                if (index == r.StartIndex) return token.Split(node, false);
                if (index < r.EndIndex) return SplitNode(token, node, index, false);
            }
        }
示例#6
0
        static ElementToken SplitNode(ElementToken token, LinkedListNode<ParseToken> node, int index, bool back)
        {
            var curToken = node.Value;

            ParseToken newToken = null;
            if (curToken is TextToken)
            {
                // split text
                newToken = ((TextToken)curToken).Split(index);
            }
            else if (curToken is ElementToken)
            {
                newToken = back
                                             ? SplitBack((ElementToken)curToken, index)
                                             : Split((ElementToken)curToken, index);
            }

            // add new node after curNode
            token.Tokens.AddAfter(node, newToken);

            // split by node
            return token.Split(node, true);
        }