Skip to content

Commit 7e365ed

Browse files
committed
unified: Elaborate on getEnclosingCallable
1 parent 1229b22 commit 7e365ed

1 file changed

Lines changed: 10 additions & 1 deletion

File tree

unified/ql/lib/codeql/unified/internal/FacadeAst.qll

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,16 @@ module Unified {
4242
)
4343
}
4444

45-
/** Gets the nearest callable containing this AST node. */
45+
/**
46+
* Gets the nearest callable containing this AST node.
47+
*
48+
* If this node is itself a callable, this gets the outer callable, not the node itself.
49+
*
50+
* Note that the `TopLevel` is callable, so all nodes other than the `TopLevel` itself has an enclosing callable.
51+
*
52+
* In some cases this predicate skips overs the syntactically-enclosing callable in order to get the callable in which
53+
* the AST is actually evaluated (such as for capture declarations in a function expression).
54+
*/
4655
Callable getEnclosingCallable() {
4756
exists(AstNode parent |
4857
parent = this.overrideEnclosingCallableParent()

0 commit comments

Comments
 (0)