@@ -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
@@ -1062,6 +1066,20 @@ module Exprs {
10621066 }
10631067 }
10641068
1069+ class KeyPathTree extends AstLeafTree {
1070+ override KeyPathExpr ast ;
1071+ }
1072+
1073+ class KeyPathApplicationTree extends AstStandardPostOrderTree {
1074+ override KeyPathApplicationExpr ast ;
1075+
1076+ final override ControlFlowElement getChildElement ( int i ) {
1077+ i = 0 and result .asAstNode ( ) = ast .getBase ( ) .getFullyConverted ( )
1078+ or
1079+ i = 1 and result .asAstNode ( ) = ast .getKeyPath ( ) .getFullyConverted ( )
1080+ }
1081+ }
1082+
10651083 private class InOutTree extends AstStandardPostOrderTree {
10661084 override InOutExpr ast ;
10671085
@@ -1586,7 +1604,9 @@ private module Cached {
15861604 result = scopeOfAst ( n .asAstNode ( ) ) or
15871605 result = scopeOfAst ( n .( PropertyGetterElement ) .getRef ( ) ) or
15881606 result = scopeOfAst ( n .( PropertySetterElement ) .getAssignExpr ( ) ) or
1589- result = scopeOfAst ( n .( PropertyObserverElement ) .getAssignExpr ( ) )
1607+ result = scopeOfAst ( n .( PropertyObserverElement ) .getAssignExpr ( ) ) or
1608+ result = n .( FuncDeclElement ) .getAst ( ) or
1609+ result = n .( KeyPathElement ) .getAst ( )
15901610 }
15911611
15921612 cached
0 commit comments