public static SwapInfo Swap(this TextDocument document, int xStart, int xLength, int yStart, int yLength)
        {
            if (xStart > yStart)
            {
                (xStart, yStart)   = (yStart, xStart);
                (xLength, yLength) = (yLength, xLength);
            }

            if (xStart + xLength > yStart)
            {
                throw new ArgumentException();
            }

            var xText = document.GetText(xStart, xLength);
            var yText = document.GetText(yStart, yLength);

            var intervalText = document.GetText(xStart + xLength, yStart - (xStart + xLength));

            var newTest = yText + intervalText + xText;

            var offsetChangeMap = new OffsetChangeMap()
            {
                new OffsetChangeMapEntry(yStart, yLength, xLength),
                new OffsetChangeMapEntry(xStart, xLength, yLength),
            };

            document.Replace(xStart, newTest.Length, newTest, offsetChangeMap);
            return(SwapInfo.CreateFrom(new SwapInfo.SwapNode(xStart, xText), new SwapInfo.SwapNode(yStart, yText)));
        }
 static public bool TryCreateSwapInfo(this DocumentChangeEventArgs e, out SwapInfo?info)
 {
     info = SwapInfo.CreateFrom(e);
     return(info != null);
 }
 static public SwapInfo?TryCreateSwapInfo(this DocumentChangeEventArgs e)
 {
     return(SwapInfo.CreateFrom(e));
 }