mirror of
https://github.com/github/codeql.git
synced 2026-04-29 10:45:15 +02:00
Ruby: add tree-sitter test case
This commit is contained in:
5846
ruby/ql/test/library-tests/ast/TreeSitter.expected
Normal file
5846
ruby/ql/test/library-tests/ast/TreeSitter.expected
Normal file
File diff suppressed because it is too large
Load Diff
31
ruby/ql/test/library-tests/ast/TreeSitter.ql
Normal file
31
ruby/ql/test/library-tests/ast/TreeSitter.ql
Normal file
@@ -0,0 +1,31 @@
|
||||
/**
|
||||
* @kind graph
|
||||
*/
|
||||
|
||||
import codeql.ruby.ast.internal.TreeSitter::Ruby
|
||||
|
||||
/**
|
||||
* Holds if `node` belongs to the output tree, and its property `key` has the
|
||||
* given `value`.
|
||||
*/
|
||||
query predicate nodes(AstNode node, string key, string value) {
|
||||
key = "semmle.label" and
|
||||
value = "[" + node.getPrimaryQlClasses() + "] " + node.toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if `target` is a child of `source` in the AST, and property `key` of
|
||||
* the edge has the given `value`.
|
||||
*/
|
||||
query predicate edges(AstNode source, AstNode target, string key, string value) {
|
||||
source = target.getParent() and
|
||||
key = ["semmle.label", "semmle.order"] and
|
||||
value = target.getParentIndex().toString()
|
||||
}
|
||||
|
||||
/**
|
||||
* Holds if property `key` of the graph has the given `value`.
|
||||
*/
|
||||
query predicate graphProperties(string key, string value) {
|
||||
key = "semmle.graphKind" and value = "tree"
|
||||
}
|
||||
Reference in New Issue
Block a user