aboutsummaryrefslogtreecommitdiff
path: root/core/src/main/java/coffee/liz/lambda/ast/SourceSpan.java
blob: 7df9bcd3829240ef0d0de11de31b4220017a0589 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
package coffee.liz.lambda.ast;

/**
 * Span of source code with start and end positions.
 *
 * @param startLine
 *            1-based line number where the span starts
 * @param startColumn
 *            1-based column number where the span starts
 * @param endLine
 *            1-based line number where the span ends
 * @param endColumn
 *            1-based column number where the span ends
 */
public record SourceSpan(int startLine, int startColumn, int endLine, int endColumn) {
	public static final SourceSpan UNKNOWN = new SourceSpan(0, 0, 0, 0);

	/**
	 * Returns true if this span ends on the same line that the other span starts.
	 */
	public boolean isOnSameLine(final SourceSpan other) {
		return this.endLine == other.startLine;
	}
}