Files
codeql/ruby/downgrades/3595c826de6db850f16b9da265a54dbf24dd3126/ruby_ast_node_info.ql
2022-08-25 17:40:52 +02:00

29 lines
881 B
Plaintext

class AstNode extends @ruby_ast_node_parent {
string toString() { none() }
}
class Location extends @location {
string toString() { none() }
}
class Wrapper = @ruby_body_statement or @ruby_block_body;
predicate astNodeInfo(AstNode child, AstNode parent, int primaryIndex, int secondaryIndex) {
not parent instanceof Wrapper and
exists(AstNode node, Location l |
ruby_ast_node_info(node, parent, primaryIndex, _) and
(
not node instanceof Wrapper and secondaryIndex = 0 and child = node
or
node instanceof Wrapper and ruby_ast_node_info(child, node, secondaryIndex, _)
)
)
}
from AstNode node, AstNode parent, int parent_index, Location loc
where
node =
rank[parent_index + 1](AstNode n, int i, int j | astNodeInfo(n, parent, i, j) | n order by i, j) and
ruby_ast_node_info(node, _, _, loc)
select node, parent, parent_index, loc