Line

class Line(source: CharSequence, val start: Int, val end: Int, val nextStart: Int)

A single line of a scanned source, with its indentation precomputed. Lines are produced once per source by Lines.of and never re-sliced.

Parameters

source

the whole source the line belongs to

start

index of the line's first character within source

end

index just past the line's last character, line terminator excluded

nextStart

index of the next line's first character, or end at the end of input

Constructors

Link copied to clipboard
constructor(source: CharSequence, start: Int, end: Int, nextStart: Int)

Properties

Link copied to clipboard

Text of the line after its leading whitespace, terminator excluded. Allocates on first access.

Link copied to clipboard

Index of the first non-whitespace character, or end when the line is blank.

Link copied to clipboard
val end: Int
Link copied to clipboard
val indent: Int

Columns of leading whitespace, tabs expanded to TAB_WIDTH stops.

Link copied to clipboard

Whether the line holds no non-whitespace character.

Link copied to clipboard

Whether the line holds no character at all, as opposed to isBlank, which also holds for a line of whitespace.

Link copied to clipboard

Whether the line is terminated by a newline, as opposed to ending at the end of input.

Link copied to clipboard

Amount of literal spaces the line starts with, tabs excluded. A list's resumption is defined in spaces, where indent is defined in columns.

Link copied to clipboard
Link copied to clipboard
val start: Int
Link copied to clipboard

Raw text of the line, terminator excluded. Allocates on first access.

Functions

Link copied to clipboard
fun charAt(index: Int): Char?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
fun Line.scanner(from: Int = start, to: Int = end): Scanner
Link copied to clipboard
Link copied to clipboard
fun sourceSlice(start: Int, end: Int): String