Skip to content

Commit c82690f

Browse files
committed
JS: address comments
1 parent cc1204a commit c82690f

File tree

1 file changed

+14
-8
lines changed
  • javascript/ql/src/semmle/javascript/dataflow

1 file changed

+14
-8
lines changed

javascript/ql/src/semmle/javascript/dataflow/Nodes.qll

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,8 @@ DataFlow::SourceNode moduleMember(string path, string m) {
488488
* method: function() {}
489489
* });
490490
* ```
491+
*
492+
* Additional patterns can be recognized as class nodes, by extending `DataFlow::ClassNode::Range`.
491493
*/
492494
class ClassNode extends DataFlow::SourceNode {
493495
ClassNode::Range impl;
@@ -510,24 +512,28 @@ class ClassNode extends DataFlow::SourceNode {
510512
FunctionNode getConstructor() { result = impl.getConstructor() }
511513

512514
/**
513-
* Gets an instance method with the given name, if any.
515+
* Gets an instance method declared in this class, with the given name, if any.
516+
*
517+
* Does not include methods from superclasses.
514518
*/
515519
FunctionNode getInstanceMethod(string name) { result = impl.getInstanceMethod(name) }
516520

517521
/**
518-
* Gets an instance method of this class.
522+
* Gets an instance method declared in this class.
519523
*
520524
* The constructor is not considered an instance method.
525+
*
526+
* Does not include methods from superclasses.
521527
*/
522528
FunctionNode getAnInstanceMethod() { result = impl.getAnInstanceMethod() }
523529

524530
/**
525-
* Gets the static method of this class with the given name.
531+
* Gets the static method declared in this class with the given name.
526532
*/
527533
FunctionNode getStaticMethod(string name) { result = impl.getStaticMethod(name) }
528534

529535
/**
530-
* Gets a static method of this class.
536+
* Gets a static method declared in this class.
531537
*
532538
* The constructor is not considered a static method.
533539
*/
@@ -619,12 +625,12 @@ module ClassNode {
619625
result = method.getBody().flow()
620626
)
621627
or
622-
result = getAPropertyWrite(name).getRhs().getALocalSource()
628+
result = getAPropertySource(name)
623629
}
624630

625631
override FunctionNode getAStaticMethod() {
626632
exists(MethodDeclaration method |
627-
method = astNode.(ClassDefinition).getAMethod() and
633+
method = astNode.getAMethod() and
628634
method.isStatic() and
629635
result = method.getBody().flow()
630636
)
@@ -646,15 +652,15 @@ module ClassNode {
646652
override FunctionNode getConstructor() { result = this }
647653

648654
override FunctionNode getInstanceMethod(string name) {
649-
result = getAPrototypeReference().getAPropertyWrite(name).getRhs().getALocalSource()
655+
result = getAPrototypeReference().getAPropertySource(name)
650656
}
651657

652658
override FunctionNode getAnInstanceMethod() {
653659
result = getAPrototypeReference().getAPropertyWrite().getRhs().getALocalSource()
654660
}
655661

656662
override FunctionNode getStaticMethod(string name) {
657-
result = getAPropertyWrite(name).getRhs().getALocalSource()
663+
result = getAPropertySource(name)
658664
}
659665

660666
override FunctionNode getAStaticMethod() {

0 commit comments

Comments
 (0)