mirror of
https://github.com/github/codeql.git
synced 2025-12-17 01:03:14 +01:00
Merge pull request #17690 from hvitved/rust/ast-consistency-queries
Rust: Add AST consistency queries
This commit is contained in:
21
rust/ql/consistency-queries/AstConsistency.ql
Normal file
21
rust/ql/consistency-queries/AstConsistency.ql
Normal file
@@ -0,0 +1,21 @@
|
||||
import rust
|
||||
import codeql.rust.elements.internal.generated.ParentChild
|
||||
|
||||
query predicate multipleToString(Element e, string s) {
|
||||
s = strictconcat(e.toString(), ",") and
|
||||
strictcount(e.toString()) > 1
|
||||
}
|
||||
|
||||
query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) > 1 }
|
||||
|
||||
query predicate multiplePrimaryQlClasses(Element e, string s) {
|
||||
s = e.getPrimaryQlClasses() and
|
||||
strictcount(e.getAPrimaryQlClass()) > 1
|
||||
}
|
||||
|
||||
private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }
|
||||
|
||||
query predicate multipleParents(Element child, Element parent) {
|
||||
parent = getParent(child) and
|
||||
strictcount(getParent(child)) > 1
|
||||
}
|
||||
Reference in New Issue
Block a user