public final class SourceSpan extends Object
[startLine:startColumn,
endLine:endColumn). Used by Diagnostic to point at the
offending AST node when a reject site has one in scope.
startLine / startColumn mark the first character
of the anchor (1-based as populated by GSP's lexer via
TSourceToken.lineNo / TSourceToken.columnNo).
endLine / endColumn mark the position
one past the last character. For a single-line
single-token anchor of length L, endColumn ==
startColumn + L. Multi-line tokens (e.g. triple-quoted strings)
are handled by counting newlines in the end token's text.
The class is intentionally null-tolerant at the factory level:
of(TParseTreeNode) returns null when the node or
either of its boundary tokens is null. Diagnostic factories
pass this null through to Diagnostic.getSpan()
unchanged.
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object o) |
long |
getEndColumn() |
long |
getEndLine() |
long |
getStartColumn() |
long |
getStartLine() |
int |
hashCode() |
static SourceSpan |
of(TParseTreeNode node)
Derive a span from the AST node's start and end tokens.
|
static SourceSpan |
of(TSourceToken start,
TSourceToken end)
Derive a span from explicit start / end tokens.
|
String |
toString() |
public static SourceSpan of(TParseTreeNode node)
null when node is null
or either boundary token is null.public static SourceSpan of(TSourceToken start, TSourceToken end)
end so the
resulting interval is half-open [start, end).
Null-safe: returns null when either token is
null.
public long getStartLine()
public long getStartColumn()
public long getEndLine()
public long getEndColumn()