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

import lombok.NonNull;

/**
 * A comment with its source location; inline vs leading direction.
 *
 * @param text
 *            the comment text content
 * @param span
 *            the source location of the comment
 */
public record SourceComment(@NonNull String text, @NonNull SourceSpan span) {

	/**
	 * Returns true if this comment is on the same line as the given span's end.
	 */
	public boolean isInlineAfter(final SourceSpan previous) {
		return previous != null && previous.endLine() == this.span.startLine();
	}
}