Skip to content

Commit 4eaa31d

Browse files
committed
Add hasName predicates
1 parent 2d08b01 commit 4eaa31d

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

ql/lib/codeql/ruby/ast/Constant.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ class ConstantAccess extends Expr, TConstantAccess {
99
/** Gets the name of the constant being accessed. */
1010
string getName() { none() }
1111

12+
/** Holds if the name of the constant being accessed is `name`. */
13+
final predicate hasName(string name) { this.getName() = name }
14+
1215
/**
1316
* Gets the expression used in the access's scope resolution operation, if
1417
* any. In the following example, the result is the `Call` expression for

ql/lib/codeql/ruby/ast/Method.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class MethodBase extends Callable, BodyStmt, Scope, TMethodBase {
2626
/** Gets the name of this method. */
2727
string getName() { none() }
2828

29+
/** Holds if the name of this method is `name`. */
30+
final predicate hasName(string name) { this.getName() = name }
31+
2932
override AstNode getAChild(string pred) {
3033
result = Callable.super.getAChild(pred)
3134
or

ql/lib/codeql/ruby/ast/Parameter.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class NamedParameter extends Parameter, TNamedParameter {
4545
/** Gets the name of this parameter. */
4646
string getName() { none() }
4747

48+
/** Holds if the name of this parameter is `name`. */
49+
final predicate hasName(string name) { this.getName() = name }
50+
4851
/** Gets the variable introduced by this parameter. */
4952
LocalVariable getVariable() { none() }
5053

ql/lib/codeql/ruby/ast/Variable.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ class Variable extends TVariable {
1111
/** Gets the name of this variable. */
1212
string getName() { none() }
1313

14+
/** Holds if the name of this variable is `name`. */
15+
final predicate hasName(string name) { this.getName() = name }
16+
1417
/** Gets a textual representation of this variable. */
1518
final string toString() { result = this.getName() }
1619

0 commit comments

Comments
 (0)