Пример #1
0
        public void Shift(int offset)
        {
            if (NameToken != null)
            {
                NameToken.Shift(offset);
            }

            if (EqualsSign >= 0)
            {
                EqualsSign += offset;
            }

            if (ValueToken != null)
            {
                ValueToken.Shift(offset);
            }
        }
Пример #2
0
        public void ShiftStartingFrom(int start, int offset)
        {
            if (NameToken != null && NameToken.Start >= start)
            {
                Debug.Assert(!(start > NameToken.Start && start < NameToken.End), "Can't shift when start position is in the middle of a token");
                NameToken.Shift(offset);
            }

            if (EqualsSign >= start)
            {
                EqualsSign += offset;
            }

            if (ValueToken != null)
            {
                if (ValueToken.Start >= start)
                {
                    var composite = ValueToken as CompositeAttributeValueToken;
                    if (composite != null)
                    {
                        composite.ShiftStartingFrom(start, offset);
                    }
                    else if (ValueToken.Start >= start)
                    {
                        ValueToken.Shift(offset);
                    }
                }
                else if (ValueToken.Contains(start))
                {
                    var expandable = ValueToken as IExpandableTextRange;

                    if (expandable != null)
                    {
                        expandable.Expand(0, offset);
                    }
                }
            }
        }