Files
codeql/rust/ql/test/TestUtils.qll
2026-06-02 14:41:27 +02:00

32 lines
704 B
Plaintext

private import rust
predicate toBeTested(Element e) {
not e instanceof CrateElement and
not e instanceof Builtin and
(
not e instanceof Locatable
or
exists(e.(Locatable).getFile().getRelativePath())
)
}
class CrateElement extends Element {
CrateElement() {
this instanceof Crate or
this instanceof NamedCrate
}
}
class Builtin extends AstNode {
Builtin() { this.getFile().getAbsolutePath().matches("%/builtins/%.rs") }
}
predicate commentAt(string text, string filepath, int line) {
exists(Comment c |
c.getLocation().hasLocationInfo(filepath, line, _, _, _) and
c.getCommentText().trim() = text and
c.fromSource() and
not text.matches("$%")
)
}