mirror of
https://github.com/github/codeql.git
synced 2025-12-20 10:46:30 +01:00
JS: add FunctionNode.getThisParameter
This commit is contained in:
@@ -311,6 +311,25 @@ class FunctionNode extends DataFlow::ValueNode, DataFlow::DefaultSourceNode {
|
||||
Function getFunction() {
|
||||
result = astNode
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the function whose `this` binding a `this` expression in this function refers to,
|
||||
* which is the nearest enclosing non-arrow function.
|
||||
*/
|
||||
FunctionNode getThisBinder() {
|
||||
result.getFunction() = getFunction().getThisBinder()
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets the dataflow node holding the value of the `this` argument passed to the given function.
|
||||
*
|
||||
* Has no result for arrow functions, as they ignore the receiver argument.
|
||||
*
|
||||
* To get the data flow node for `this` in an arrow function, consider using `getThisBinder().getThisParameter()`.
|
||||
*/
|
||||
ThisNode getThisParameter() {
|
||||
result.getBinder() = this
|
||||
}
|
||||
}
|
||||
|
||||
/** A data flow node corresponding to an object literal expression. */
|
||||
|
||||
Reference in New Issue
Block a user