Class OriginalSourceDocument
Represents a user-authored source document and owns its display coordinate mapping.
public abstract class OriginalSourceDocument : SourceDocument
- Inheritance
-
OriginalSourceDocument
- Derived
- Inherited Members
Remarks
Original documents are the final diagnostic coordinate space. Mapped or preprocessed documents ultimately resolve their locations to OriginalSourceSpan values backed by instances of this type.
Constructors
OriginalSourceDocument(string)
Creates an original source document from an identifier and contents string.
public OriginalSourceDocument(string identifier)
Parameters
identifierstringThe document's identifier.
Properties
Identifier
Gets the document's identifier. This is typically a path.
public override string Identifier { get; }
Property Value
- string
The document's identifier.
LineCount
public int LineCount { get; }
Property Value
Methods
GetLineByOffset(int)
Gets the display line that contains a document offset.
public SourceLine GetLineByOffset(int offset)
Parameters
offsetintThe document offset.
Returns
- SourceLine
The source line that contains the offset.
GetPosition(int)
Gets the diagnostic display position that corresponds to a particular offset in this document.
public override LineAndColumnPosition GetPosition(int offset)
Parameters
offsetintThe offset to a character in the document.
Returns
- LineAndColumnPosition
A diagnostic display position.
ResolveSpan(int, int)
Resolves a span in this document to its original source coverage.
public override ResolvedSourceSpan ResolveSpan(int start, int length)
Parameters
startintThe zero-based start offset within this document.
lengthintThe span length within this document.
Returns
- ResolvedSourceSpan
The resolved original source coverage.
TryGetLine(int, out SourceLine)
Tries to get a display line by its zero-based line index.
public bool TryGetLine(int lineIndex, out SourceLine line)
Parameters
lineIndexintThe zero-based line index.
lineSourceLineThe source line, if it exists.
Returns
- bool
trueif the line exists; otherwise,false.
TryGetOffset(int, int, out int)
Tries to convert one-based line and column coordinates to an offset.
public bool TryGetOffset(int line, int column, out int offset)
Parameters
lineintThe one-based line.
columnintThe one-based column.
offsetintThe resulting offset, if the coordinates are valid.
Returns
- bool
trueif an offset could be computed; otherwise,false.