mirror of
https://github.com/github/codeql.git
synced 2026-04-23 07:45:17 +02:00
Add hasName predicates
This commit is contained in:
@@ -9,6 +9,9 @@ class ConstantAccess extends Expr, TConstantAccess {
|
||||
/** Gets the name of the constant being accessed. */
|
||||
string getName() { none() }
|
||||
|
||||
/** Holds if the name of the constant being accessed is `name`. */
|
||||
final predicate hasName(string name) { this.getName() = name }
|
||||
|
||||
/**
|
||||
* Gets the expression used in the access's scope resolution operation, if
|
||||
* any. In the following example, the result is the `Call` expression for
|
||||
|
||||
@@ -26,6 +26,9 @@ class MethodBase extends Callable, BodyStmt, Scope, TMethodBase {
|
||||
/** Gets the name of this method. */
|
||||
string getName() { none() }
|
||||
|
||||
/** Holds if the name of this method is `name`. */
|
||||
final predicate hasName(string name) { this.getName() = name }
|
||||
|
||||
override AstNode getAChild(string pred) {
|
||||
result = Callable.super.getAChild(pred)
|
||||
or
|
||||
|
||||
@@ -45,6 +45,9 @@ class NamedParameter extends Parameter, TNamedParameter {
|
||||
/** Gets the name of this parameter. */
|
||||
string getName() { none() }
|
||||
|
||||
/** Holds if the name of this parameter is `name`. */
|
||||
final predicate hasName(string name) { this.getName() = name }
|
||||
|
||||
/** Gets the variable introduced by this parameter. */
|
||||
LocalVariable getVariable() { none() }
|
||||
|
||||
|
||||
@@ -11,6 +11,9 @@ class Variable extends TVariable {
|
||||
/** Gets the name of this variable. */
|
||||
string getName() { none() }
|
||||
|
||||
/** Holds if the name of this variable is `name`. */
|
||||
final predicate hasName(string name) { this.getName() = name }
|
||||
|
||||
/** Gets a textual representation of this variable. */
|
||||
final string toString() { result = this.getName() }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user