Table of Contents

Class TextLineMap

Namespace
MuLang.Core.Text
Assembly
MuLang.Core.dll

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

length int

The source length in Unicode scalar values.

lineStarts IEnumerable<int>

The zero-based Unicode scalar offsets at which source lines begin.

Exceptions

ArgumentNullException

Thrown when lineStarts is null.

ArgumentOutOfRangeException

Thrown when length is 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

int

LineCount

Gets the number of source lines.

public int LineCount { get; }

Property Value

int

LineStarts

Gets the zero-based Unicode scalar offsets at which source lines begin.

public IReadOnlyList<int> LineStarts { get; }

Property Value

IReadOnlyList<int>

Methods

GetLocation(TextSpan, Uri?)

Creates a materialized source location for a span.

public TextLocation GetLocation(TextSpan span, Uri? sourceDocument = null)

Parameters

span TextSpan

The source span.

sourceDocument Uri

The source document URI, when available.

Returns

TextLocation

The corresponding source location.

Exceptions

ArgumentException

Thrown when sourceDocument is not absolute.

ArgumentOutOfRangeException

Thrown when span is 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

line int

The one-based line number.

column int

The one-based column number.

Returns

int

The corresponding Unicode scalar offset.

Exceptions

ArgumentOutOfRangeException

Thrown when line or column is outside the source bounds.

GetPosition(int)

Gets the line and column for a Unicode scalar offset.

public TextPosition GetPosition(int offset)

Parameters

offset int

The Unicode scalar offset.

Returns

TextPosition

The corresponding source position.

Exceptions

ArgumentOutOfRangeException

Thrown when offset is outside the source bounds.