mirror of
https://github.com/github/codeql.git
synced 2026-05-05 21:55:19 +02:00
Merge pull request #261 from github/getPrimaryQlClasses
Implement getPrimaryQlClasses
This commit is contained in:
@@ -1,17 +1,11 @@
|
||||
import codeql.ruby.AST
|
||||
import codeql.ruby.ast.internal.Synthesis
|
||||
|
||||
private string getAPrimaryQlClass(AstNode node) {
|
||||
result = node.getAPrimaryQlClass()
|
||||
or
|
||||
not exists(node.getAPrimaryQlClass()) and result = "(none)"
|
||||
}
|
||||
|
||||
query predicate missingParent(AstNode node, string cls) {
|
||||
not exists(node.getParent()) and
|
||||
node.getLocation().getFile().getExtension() != "erb" and
|
||||
not node instanceof Toplevel and
|
||||
cls = getAPrimaryQlClass(node)
|
||||
cls = node.getPrimaryQlClasses()
|
||||
}
|
||||
|
||||
pragma[noinline]
|
||||
@@ -22,7 +16,7 @@ private AstNode parent(AstNode child, int desugarLevel) {
|
||||
|
||||
query predicate multipleParents(AstNode node, AstNode parent, string cls) {
|
||||
parent = node.getParent() and
|
||||
cls = getAPrimaryQlClass(parent) and
|
||||
cls = parent.getPrimaryQlClasses() and
|
||||
exists(AstNode one, AstNode two, int desugarLevel |
|
||||
one = parent(node, desugarLevel) and
|
||||
two = parent(node, desugarLevel) and
|
||||
|
||||
@@ -32,6 +32,12 @@ class AstNode extends TAstNode {
|
||||
*/
|
||||
string getAPrimaryQlClass() { result = "???" }
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to
|
||||
* which this element belongs.
|
||||
*/
|
||||
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
|
||||
|
||||
/** Gets the enclosing module, if any. */
|
||||
ModuleBase getEnclosingModule() {
|
||||
exists(Scope::Range s |
|
||||
|
||||
@@ -26,6 +26,9 @@ module Ruby {
|
||||
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
string getAPrimaryQlClass() { result = "???" }
|
||||
|
||||
/** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */
|
||||
string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
|
||||
}
|
||||
|
||||
/** A token. */
|
||||
@@ -1864,6 +1867,9 @@ module Erb {
|
||||
|
||||
/** Gets the name of the primary QL class for this element. */
|
||||
string getAPrimaryQlClass() { result = "???" }
|
||||
|
||||
/** Gets a comma-separated list of the names of the primary CodeQL classes to which this element belongs. */
|
||||
string getPrimaryQlClasses() { result = concat(getAPrimaryQlClass(), ",") }
|
||||
}
|
||||
|
||||
/** A token. */
|
||||
|
||||
@@ -18,10 +18,15 @@ class RegExpParent extends TRegExpParent {
|
||||
|
||||
/**
|
||||
* Gets the name of a primary CodeQL class to which this regular
|
||||
* expression
|
||||
* term belongs.
|
||||
* expression term belongs.
|
||||
*/
|
||||
string getAPrimaryQlClass() { result = "RegExpParent" }
|
||||
|
||||
/**
|
||||
* Gets a comma-separated list of the names of the primary CodeQL classes to
|
||||
* which this regular expression term belongs.
|
||||
*/
|
||||
final string getPrimaryQlClasses() { result = concat(this.getAPrimaryQlClass(), ",") }
|
||||
}
|
||||
|
||||
class RegExpLiteral extends TRegExpLiteral, RegExpParent {
|
||||
|
||||
Reference in New Issue
Block a user