inline Location into the shared implementation of InlineExpectationsTest

This commit is contained in:
erik-krogh
2022-12-22 11:09:43 +01:00
parent 08e9d3391f
commit b3dd50bc36
9 changed files with 172 additions and 164 deletions

View File

@@ -5,31 +5,27 @@
private import ql as QL
private import codeql.util.test.InlineExpectationsTest
private import codeql_ql.ast.internal.TreeSitter as TS
private module Impl implements InlineExpectationsTestSig {
private import codeql_ql.ast.internal.TreeSitter as TS
private newtype TExpectationComment = MkExpectationComment(TS::QL::LineComment comment)
private newtype TExpectationComment = MkExpectationComment(TS::QL::LineComment comment)
/**
* Represents a line comment.
*/
private class ExpectationComment extends TExpectationComment {
TS::QL::LineComment comment;
/**
* Represents a line comment.
*/
class ExpectationComment extends TExpectationComment {
TS::QL::LineComment comment;
ExpectationComment() { this = MkExpectationComment(comment) }
ExpectationComment() { this = MkExpectationComment(comment) }
/** Returns the contents of the given comment, _without_ the preceding comment marker (`//`). */
string getContents() { result = comment.getValue().suffix(2) }
/** Returns the contents of the given comment, _without_ the preceding comment marker (`//`). */
string getContents() { result = comment.getValue().suffix(2) }
/** Gets a textual representation of this element. */
string toString() { result = comment.toString() }
/** Gets a textual representation of this element. */
string toString() { result = comment.toString() }
/** Gets the location of this comment. */
Location getLocation() { result = comment.getLocation() }
predicate hasLocationInfo(string file, int line, int column, int endLine, int endColumn) {
comment.getLocation().hasLocationInfo(file, line, column, endLine, endColumn)
}
class Location = QL::Location;
}
import Make<Impl>
import Make<ExpectationComment>