Add support for InlineExpectationsTest to Kotlin

This commit is contained in:
Tony Torralba
2022-05-17 10:55:00 +02:00
parent 3b07fe70a1
commit 2b6d7bb3d8

View File

@@ -4,9 +4,19 @@ import java
* A class representing line comments in Java, which is simply Javadoc restricted
* to EOL comments, with an extra accessor used by the InlineExpectations core code
*/
class ExpectationComment extends Javadoc {
ExpectationComment() { isEolComment(this) }
abstract class ExpectationComment extends Top {
/** Gets the contents of the given comment, _without_ the preceding comment marker (`//`). */
string getContents() { result = this.getChild(0).toString() }
abstract string getContents();
}
private class JavadocExpectationComment extends Javadoc, ExpectationComment {
JavadocExpectationComment() { isEolComment(this) }
override string getContents() { result = this.getChild(0).toString() }
}
private class KtExpectationComment extends KtComment, ExpectationComment {
override string getContents() {
result = this.getText().regexpCapture("(?://|/\\*)(.*)(?:\\*/)?", 1)
}
}