Class TextLineMap
Represents source line boundaries indexed by Unicode scalar offsets.
public sealed class TextLineMap
- Inheritance
-
TextLineMap
- Inherited Members
Constructors
TextLineMap(int, IEnumerable<int>)
Initializes a new instance of the TextLineMap class.
public TextLineMap(int length, IEnumerable<int> lineStarts)
Parameters
lengthintThe source length in Unicode scalar values.
lineStartsIEnumerable<int>The zero-based Unicode scalar offsets at which source lines begin.
Exceptions
- ArgumentNullException
Thrown when
lineStartsisnull.- ArgumentOutOfRangeException
Thrown when
lengthis negative.- ArgumentException
Thrown when the line starts do not describe a valid source.
Properties
Length
Gets the source length in Unicode scalar values.
public int Length { get; }
Property Value
LineCount
Gets the number of source lines.
public int LineCount { get; }
Property Value
LineStarts
Gets the zero-based Unicode scalar offsets at which source lines begin.
public IReadOnlyList<int> LineStarts { get; }
Property Value
Methods
GetLocation(TextSpan, Uri?)
Creates a materialized source location for a span.
public TextLocation GetLocation(TextSpan span, Uri? sourceDocument = null)
Parameters
spanTextSpanThe source span.
sourceDocumentUriThe source document URI, when available.
Returns
- TextLocation
The corresponding source location.
Exceptions
- ArgumentException
Thrown when
sourceDocumentis not absolute.- ArgumentOutOfRangeException
Thrown when
spanis outside the source bounds.- OverflowException
Thrown when the span end exceeds MaxValue.
GetOffset(int, int)
Gets the Unicode scalar offset for a one-based line and column.
public int GetOffset(int line, int column)
Parameters
Returns
- int
The corresponding Unicode scalar offset.
Exceptions
- ArgumentOutOfRangeException
Thrown when
lineorcolumnis outside the source bounds.
GetPosition(int)
Gets the line and column for a Unicode scalar offset.
public TextPosition GetPosition(int offset)
Parameters
offsetintThe Unicode scalar offset.
Returns
- TextPosition
The corresponding source position.
Exceptions
- ArgumentOutOfRangeException
Thrown when
offsetis outside the source bounds.