Add hasName predicates

This commit is contained in:
Tom Hvitved
2021-09-01 13:32:19 +02:00
parent 2d08b0156a
commit 4eaa31d800
4 changed files with 12 additions and 0 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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() }

View File

@@ -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() }