This commit is contained in:
Asger F 2019-01-15 13:14:10 +00:00
Родитель cc1204acef
Коммит c82690f4c1
1 изменённых файлов: 14 добавлений и 8 удалений

Просмотреть файл

@ -488,6 +488,8 @@ DataFlow::SourceNode moduleMember(string path, string m) {
* method: function() {}
* });
* ```
*
* Additional patterns can be recognized as class nodes, by extending `DataFlow::ClassNode::Range`.
*/
class ClassNode extends DataFlow::SourceNode {
ClassNode::Range impl;
@ -510,24 +512,28 @@ class ClassNode extends DataFlow::SourceNode {
FunctionNode getConstructor() { result = impl.getConstructor() }
/**
* Gets an instance method with the given name, if any.
* Gets an instance method declared in this class, with the given name, if any.
*
* Does not include methods from superclasses.
*/
FunctionNode getInstanceMethod(string name) { result = impl.getInstanceMethod(name) }
/**
* Gets an instance method of this class.
* Gets an instance method declared in this class.
*
* The constructor is not considered an instance method.
*
* Does not include methods from superclasses.
*/
FunctionNode getAnInstanceMethod() { result = impl.getAnInstanceMethod() }
/**
* Gets the static method of this class with the given name.
* Gets the static method declared in this class with the given name.
*/
FunctionNode getStaticMethod(string name) { result = impl.getStaticMethod(name) }
/**
* Gets a static method of this class.
* Gets a static method declared in this class.
*
* The constructor is not considered a static method.
*/
@ -619,12 +625,12 @@ module ClassNode {
result = method.getBody().flow()
)
or
result = getAPropertyWrite(name).getRhs().getALocalSource()
result = getAPropertySource(name)
}
override FunctionNode getAStaticMethod() {
exists(MethodDeclaration method |
method = astNode.(ClassDefinition).getAMethod() and
method = astNode.getAMethod() and
method.isStatic() and
result = method.getBody().flow()
)
@ -646,7 +652,7 @@ module ClassNode {
override FunctionNode getConstructor() { result = this }
override FunctionNode getInstanceMethod(string name) {
result = getAPrototypeReference().getAPropertyWrite(name).getRhs().getALocalSource()
result = getAPrototypeReference().getAPropertySource(name)
}
override FunctionNode getAnInstanceMethod() {
@ -654,7 +660,7 @@ module ClassNode {
}
override FunctionNode getStaticMethod(string name) {
result = getAPropertyWrite(name).getRhs().getALocalSource()
result = getAPropertySource(name)
}
override FunctionNode getAStaticMethod() {