Accept only EOL comments as Kotlin expectation comments

This commit is contained in:
Tony Torralba
2022-05-17 13:05:51 +02:00
parent 2b6d7bb3d8
commit dbf249b199
2 changed files with 12 additions and 3 deletions

View File

@@ -153,6 +153,15 @@ class KtComment extends Top, @ktcomment {
/** Gets the full text of this comment. */
string getText() { ktComments(this, _, result) }
/** Holds if this comment is an EOL comment. */
predicate isEolComment() { ktComments(this, 1, _) }
/** Holds if this comment is a block comment. */
predicate isBlockComment() { ktComments(this, 2, _) }
/** Holds if this comment is a KDoc comment. */
predicate isDocComment() { ktComments(this, 3, _) }
/** Gets the sections of this comment. */
KtCommentSection getSections() { ktCommentSections(result, this, _) }

View File

@@ -16,7 +16,7 @@ private class JavadocExpectationComment extends Javadoc, ExpectationComment {
}
private class KtExpectationComment extends KtComment, ExpectationComment {
override string getContents() {
result = this.getText().regexpCapture("(?://|/\\*)(.*)(?:\\*/)?", 1)
}
KtExpectationComment() { this.isEolComment() }
override string getContents() { result = this.getText().suffix(2).trim() }
}