Skip to content

Commit dbf249b

Browse files
committed
Accept only EOL comments as Kotlin expectation comments
1 parent 2b6d7bb commit dbf249b

File tree

2 files changed

+12
-3
lines changed

2 files changed

+12
-3
lines changed

java/ql/lib/semmle/code/java/Javadoc.qll

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,15 @@ class KtComment extends Top, @ktcomment {
153153
/** Gets the full text of this comment. */
154154
string getText() { ktComments(this, _, result) }
155155

156+
/** Holds if this comment is an EOL comment. */
157+
predicate isEolComment() { ktComments(this, 1, _) }
158+
159+
/** Holds if this comment is a block comment. */
160+
predicate isBlockComment() { ktComments(this, 2, _) }
161+
162+
/** Holds if this comment is a KDoc comment. */
163+
predicate isDocComment() { ktComments(this, 3, _) }
164+
156165
/** Gets the sections of this comment. */
157166
KtCommentSection getSections() { ktCommentSections(result, this, _) }
158167

java/ql/test/TestUtilities/InlineExpectationsTestPrivate.qll

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ private class JavadocExpectationComment extends Javadoc, ExpectationComment {
1616
}
1717

1818
private class KtExpectationComment extends KtComment, ExpectationComment {
19-
override string getContents() {
20-
result = this.getText().regexpCapture("(?://|/\\*)(.*)(?:\\*/)?", 1)
21-
}
19+
KtExpectationComment() { this.isEolComment() }
20+
21+
override string getContents() { result = this.getText().suffix(2).trim() }
2222
}

0 commit comments

Comments
 (0)