public static IEnumerable <Range> ToRangeSpanningLines(this IPositionable positionable, ImmutableArray <int> lineStarts)
        {
            var start = PositionHelper.GetPosition(lineStarts, positionable.Span.Position);
            var end   = PositionHelper.GetPosition(lineStarts, positionable.GetEndPosition());

            while (start.Line < end.Line)
            {
                var lineEnd = PositionHelper.GetPosition(lineStarts, lineStarts[start.Line + 1] - 1);
                yield return(new Range(start, lineEnd));

                start = new Position(start.Line + 1, 0);
            }

            yield return(new Range(start, end));
        }
 public static Range ToRange(this IPositionable positionable, ImmutableArray <int> lineStarts) =>
 new Range
 {
     Start = PositionHelper.GetPosition(lineStarts, positionable.Span.Position),
     End   = PositionHelper.GetPosition(lineStarts, positionable.GetEndPosition())
 };
Example #3
0
        public static string GetSpanText(string sourceText, IPositionable positionable)
        {
            var spanText = sourceText[new Range(positionable.Span.Position, positionable.GetEndPosition())];

            return(EscapeWhitespace(spanText));
        }