public class TokenSpan extends Object
Represents a half-open token range [start, end) within a single source line.
TokenSpan avoids allocating substring copies during line-by-line syntax highlighting. Callers can extract the underlying text on demand via slice(line).
import klyn.code
span = TokenSpan(0, 6, TokenKind.KEYWORD)
assert span.length == 6
assert span.slice("public class Foo:") == "public"| Modifier and Type | Member | Description |
|---|---|---|
| public readonly property | endend as Long |
Zero-based exclusive end offset within the line. |
| public readonly property | kindkind as TokenKind |
Lexical classification of this span. |
| public readonly property | lengthlength as Long |
Number of characters covered by this span (end - start). |
| public readonly property | startstart as Long |
Zero-based inclusive start offset within the line. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | TokenSpan | Constructs a token span covering [start, end) with the given TokenKind. |
| Modifier and Type | Member | Description |
|---|---|---|
| public | contains | Checks whether a zero-based column offset falls within [start, end). |
| public | slice | Extracts the substring covered by this span from line. |
| public override | toStringtoString() as String |
Returns a human-readable representation of this span. |