JavaScript: Add predicate AbstractCallable.getDefinition.

This commit is contained in:
Max Schaefer
2018-07-19 12:23:20 +02:00
parent 688647491e
commit 3e56e9eaf9

View File

@@ -260,8 +260,18 @@ class AbstractRegExp extends DefiniteAbstractValue, TAbstractRegExp {
abstract class AbstractCallable extends DefiniteAbstractValue {
/**
* Gets the function represented by this abstract value.
*
* For abstract class values, this is the constructor method of the class.
*/
abstract Function getFunction();
/**
* Gets the definition of the function or class represented by this abstract value.
*
* For abstract class values, this is the definition of the class itself (and not
* its constructor).
*/
abstract AST::ValueNode getDefinition();
}
/**
@@ -270,6 +280,8 @@ abstract class AbstractCallable extends DefiniteAbstractValue {
class AbstractFunction extends AbstractCallable, TAbstractFunction {
override Function getFunction() { this = TAbstractFunction(result) }
override AST::ValueNode getDefinition() { result = getFunction() }
override boolean getBooleanValue() { result = true }
override InferredType getType() { result = TTFunction() }
@@ -298,6 +310,8 @@ class AbstractClass extends AbstractCallable, TAbstractClass {
override Function getFunction() { result = getClass().getConstructor().getBody() }
override AST::ValueNode getDefinition() { result = getClass() }
override boolean getBooleanValue() { result = true }
override InferredType getType() { result = TTClass() }