public void FromSpanNotStartOfLineThrows() { var text = SourceText.From("abcdef"); Assert.Throws <ArgumentOutOfRangeException>( () => TextLine.FromSpan(text, new TextSpan(1, 5)) ); }
public void FromSpanZeroLengthWithLineBreak() { var text = SourceText.From(Environment.NewLine); var line = TextLine.FromSpan(text, new TextSpan(0, 0)); Assert.Equal("", line.ToString()); Assert.Equal(Environment.NewLine.Length, line.SpanIncludingLineBreak.Length); }
public void FromSpanNoBreaksBeforeOrAfter() { var text = SourceText.From("foo"); var line = TextLine.FromSpan(text, new TextSpan(0, 3)); Assert.Equal("foo", line.ToString()); Assert.Equal(0, line.LineNumber); }
public void FromSpanZeroLengthNotEndOfLineThrows() { var text = SourceText.From("abcdef"); Assert.Throws <ArgumentOutOfRangeException>( () => TextLine.FromSpan(text, new TextSpan(0, 0)) ); }
public void FromSpanStartsBeforeZeroThrows() { var text = SourceText.From("abcdef"); Assert.Throws <ArgumentOutOfRangeException>( () => TextLine.FromSpan(text, new TextSpan(-1, 2)) ); }
public void FromSpanLengthGreaterThanTextThrows() { var text = SourceText.From("abcdef"); Assert.Throws <ArgumentOutOfRangeException>( () => TextLine.FromSpan(text, new TextSpan(1, 10)) ); }
public void FromSpanIncludingBreaks() { var text = SourceText.From("foo" + Environment.NewLine + "bar"); var span = TextSpan.FromBounds(0, 5); var line = TextLine.FromSpan(text, span); Assert.Equal(span, line.SpanIncludingLineBreak); Assert.Equal(3, line.End); Assert.Equal(0, line.LineNumber); }
public void FromSpanNotIncludingBreaks() { var text = SourceText.From("foo" + Environment.NewLine); var span = new TextSpan(0, 3); var line = TextLine.FromSpan(text, span); Assert.Equal(span, line.Span); Assert.Equal(5, line.EndIncludingLineBreak); Assert.Equal(0, line.LineNumber); }
public void FromSpanZeroLengthAtEnd() { var text = SourceText.From("foo" + Environment.NewLine); var start = text.Length; var line = TextLine.FromSpan(text, new TextSpan(start, 0)); Assert.Equal("", line.ToString()); Assert.Equal(0, line.Span.Length); Assert.Equal(0, line.SpanIncludingLineBreak.Length); Assert.Equal(start, line.Start); Assert.Equal(start, line.Span.Start); Assert.Equal(start, line.SpanIncludingLineBreak.Start); Assert.Equal(1, line.LineNumber); }
public override TextLine this[int index] { get { if (index < 0 || index >= starts.Length) { throw new ArgumentOutOfRangeException(nameof(index)); } var start = starts[index]; if (index == starts.Length - 1) { return(TextLine.FromSpan(text, TextSpan.FromBounds(start, text.Length))); } var end = starts[index + 1]; return(TextLine.FromSpan(text, TextSpan.FromBounds(start, end))); } }
public override TextLine this[int index] { get { var line = sourceText.TextSnapshot.GetLineFromLineNumber(index); return(TextLine.FromSpan(sourceText, TextSpan.FromBounds(line.Start, line.End))); } }
public override TextLine GetLineFromPosition(int position) { var line = textDoc.GetLineByOffset(position); return(TextLine.FromSpan(parent, new TextSpan(line.Offset, line.Length))); }
public override TextLine this [int index] { get { var line = textDoc.GetLine(index + 1); return(TextLine.FromSpan(parent, new TextSpan(line.Offset, line.Length))); } }
public void FromSpanTextNullThrows() { var text = SourceText.From("abcdef"); Assert.Throws <ArgumentNullException>(() => TextLine.FromSpan(null, new TextSpan(0, 2))); }