@@ -47,19 +47,23 @@ module CfgScope {
4747 }
4848
4949 private class BodyStmtCallableScope extends Range_ instanceof AbstractFunctionDecl {
50- final override predicate entry ( ControlFlowElement first ) {
51- exists ( Decls:: FuncDeclTree tree |
52- tree .getAst ( ) = this and
53- first = tree
54- )
55- }
50+ Decls:: FuncDeclTree tree ;
5651
57- final override predicate exit ( ControlFlowElement last , Completion c ) {
58- exists ( Decls:: FuncDeclTree tree |
59- tree .getAst ( ) = this and
60- tree .last ( last , c )
61- )
62- }
52+ BodyStmtCallableScope ( ) { tree .getAst ( ) = this }
53+
54+ final override predicate entry ( ControlFlowElement first ) { first ( tree , first ) }
55+
56+ final override predicate exit ( ControlFlowElement last , Completion c ) { last ( tree , last , c ) }
57+ }
58+
59+ private class KeyPathScope extends Range_ instanceof KeyPathExpr {
60+ AstControlFlowTree tree ;
61+
62+ KeyPathScope ( ) { tree .getAst ( ) = this .getParsedRoot ( ) .getFullyConverted ( ) }
63+
64+ final override predicate entry ( ControlFlowElement first ) { first ( tree , first ) }
65+
66+ final override predicate exit ( ControlFlowElement last , Completion c ) { last ( tree , last , c ) }
6367 }
6468}
6569
@@ -1112,6 +1116,20 @@ module Exprs {
11121116 }
11131117 }
11141118
1119+ class KeyPathTree extends AstLeafTree {
1120+ override KeyPathExpr ast ;
1121+ }
1122+
1123+ class KeyPathApplicationTree extends AstStandardPostOrderTree {
1124+ override KeyPathApplicationExpr ast ;
1125+
1126+ final override ControlFlowElement getChildElement ( int i ) {
1127+ i = 0 and result .asAstNode ( ) = ast .getBase ( ) .getFullyConverted ( )
1128+ or
1129+ i = 1 and result .asAstNode ( ) = ast .getKeyPath ( ) .getFullyConverted ( )
1130+ }
1131+ }
1132+
11151133 private class InOutTree extends AstStandardPostOrderTree {
11161134 override InOutExpr ast ;
11171135
@@ -1648,7 +1666,9 @@ private module Cached {
16481666 result = scopeOfAst ( n .asAstNode ( ) ) or
16491667 result = scopeOfAst ( n .( PropertyGetterElement ) .getRef ( ) ) or
16501668 result = scopeOfAst ( n .( PropertySetterElement ) .getAssignExpr ( ) ) or
1651- result = scopeOfAst ( n .( PropertyObserverElement ) .getAssignExpr ( ) )
1669+ result = scopeOfAst ( n .( PropertyObserverElement ) .getAssignExpr ( ) ) or
1670+ result = n .( FuncDeclElement ) .getAst ( ) or
1671+ result = n .( KeyPathElement ) .getAst ( )
16521672 }
16531673
16541674 cached
0 commit comments