Vixen
02b45cc4
csharp
public sealed class SourceText

An immutable snapshot of source text with a precomputed line index, so a character offset (or TextSpan) can be mapped to a LinePosition for diagnostics. Line breaks recognised are \r\n, \n, and \r.

No guide page documents this yet — the page shows what the code says about itself.

Fields and properties (3)

  • public int Length

    Number of characters in the text.

  • public int LineCount

    Number of lines. A trailing newline yields a final empty line.

  • public char this[int position]

    The character at .

Methods (10)

  • public static SourceText From(string text)

    Snapshots a string. A null string is treated as empty.

  • public SourceText WithChanges(IEnumerable<TextChange> changes)

    Applies edits and returns the result, remembering where it differs so a reparse can ask.

  • public SourceText WithChanges(params TextChange[] changes)
  • public IReadOnlyList<TextChangeRange> GetChangeRanges(SourceText oldText)

    Where this text differs from , for an incremental reparse.

  • public string ToString(TextSpan span)

    The substring covered by .

  • public override string ToString()

    The whole text.

  • public LinePosition GetLinePosition(int position)

    Maps a character offset to its zero-based (line, character). Offsets are clamped to [0, Length] so end-of-file positions resolve cleanly.

  • public LinePositionSpan GetLinePositionSpan(TextSpan span)

    Maps a span to zero-based start and end line positions.

  • public int GetLineStart(int line)

    Start offset of the given zero-based line.

  • public string GetLineText(int line)

    The text of the given zero-based line, without its line break. Used when rendering a diagnostic under the source it points at.

Used by (25)

  • BinderVixen.Ui.Markup
  • DiagnosticFormatterVixen.Core.Syntax
  • DiagnosticsTestsVixen.Core.Syntax.Tests
  • ISyntaxTreeVixen.Core.Syntax
  • IncrementalTestsVixen.Ui.Markup.Tests
  • LocationVixen.Core.Syntax
  • RedTreeTestsVixen.Core.Syntax.Tests
  • SourceTextTestsVixen.Core.Syntax.Tests
  • SyntaxTreeVixen.Ui.Markup
  • TextChangeTestsVixen.Core.Syntax.Tests
  • ToyTreeVixen.Core.Syntax.Tests
  • VxmlLexerVixen.Ui.Markup
  • VxmlParserVixen.Ui.Markup
  • AntlrOracleVixen.Raven.Tests
  • CompileDriverVixen.Raven.Cli
  • DiagnosticFormatterTestsVixen.Raven.Tests
  • DiagnosticsTestsVixen.Raven.Tests
  • IncrementalParseTestsVixen.Raven.Tests
  • LexerDifferentialTestsVixen.Raven.Tests
  • LibraryBuilderVixen.Raven
  • ParserDifferentialTestsVixen.Raven.Tests
  • RavenLexerVixen.Raven
  • RavenParserVixen.Raven
  • RavenSyntaxErrorListenerVixen.Raven.Tests
  • SyntaxTreeVixen.Raven