Skip to content

Commit 918e435

Browse files
authored
Merge pull request github#17690 from hvitved/rust/ast-consistency-queries
Rust: Add AST consistency queries
2 parents 04d1c82 + 08d6d54 commit 918e435

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import rust
2+
import codeql.rust.elements.internal.generated.ParentChild
3+
4+
query predicate multipleToString(Element e, string s) {
5+
s = strictconcat(e.toString(), ",") and
6+
strictcount(e.toString()) > 1
7+
}
8+
9+
query predicate multipleLocations(Locatable e) { strictcount(e.getLocation()) > 1 }
10+
11+
query predicate multiplePrimaryQlClasses(Element e, string s) {
12+
s = e.getPrimaryQlClasses() and
13+
strictcount(e.getAPrimaryQlClass()) > 1
14+
}
15+
16+
private Element getParent(Element child) { child = getChildAndAccessor(result, _, _) }
17+
18+
query predicate multipleParents(Element child, Element parent) {
19+
parent = getParent(child) and
20+
strictcount(getParent(child)) > 1
21+
}

0 commit comments

Comments
 (0)