1+ class Location extends @location {
2+ /** Gets the start line of this location */
3+ int getStartLine ( ) {
4+ locations_default ( this , _, result , _, _, _) or
5+ locations_ast ( this , _, result , _, _, _)
6+ }
7+
8+ /** Gets the start column of this location */
9+ int getStartColumn ( ) {
10+ locations_default ( this , _, _, result , _, _) or
11+ locations_ast ( this , _, _, result , _, _)
12+ }
13+
14+ string toString ( ) { result = "<some file>" + ":" + this .getStartLine ( ) .toString ( ) }
15+ }
16+
117class Expr_ extends @py_expr {
218 string toString ( ) { result = "Expr" }
19+
20+ Location getLocation ( ) { py_locations ( result , this ) }
321}
422
523class ExprParent_ extends @py_expr_parent {
@@ -15,6 +33,8 @@ class ExprList_ extends @py_expr_list {
1533
1634class Parameter_ extends @py_parameter {
1735 string toString ( ) { result = "Parameter" }
36+
37+ Location getLocation ( ) { result = this .( Expr_ ) .getLocation ( ) }
1838}
1939
2040class ParameterList extends @py_parameter_list {
@@ -68,8 +88,8 @@ class Function_ extends @py_Function {
6888 string toString ( ) { result = "Function" }
6989}
7090
71-
72- /* * This class servers the same purpose as CallableExpr. CallableExpr is defined in Function.qll
91+ /**
92+ * This class servers the same purpose as CallableExpr. CallableExpr is defined in Function.qll
7393 * To ease the burden of number of classes that needs to be implemented here, I make the class
7494 * hierarchy slightly different (that's why it's called Adjusted)
7595 */
@@ -85,7 +105,6 @@ abstract class CallableExprAdjusted extends Expr_ {
85105 abstract Function_ getInnerScope ( ) ;
86106}
87107
88-
89108class Lambda_ extends @py_Lambda, CallableExprAdjusted , Expr_ {
90109 /** Gets the arguments of this lambda expression. */
91110 override Arguments_ getArgs ( ) { py_arguments ( result , this ) }
@@ -119,5 +138,19 @@ where
119138 args .getDefault ( oldidx ) = id and
120139 newidx = oldidx + count ( callable .getInnerScope ( ) .getArg ( _) ) - count ( args .getDefault ( _) )
121140 )
141+ or
142+ exists ( Arguments_ args , CallableExprAdjusted callable |
143+ callable .getArgs ( ) = args and
144+ args .getKwDefault ( oldidx ) = id and
145+ newidx =
146+ max ( int i |
147+ exists ( Parameter_ param | param = callable .getInnerScope ( ) .getKwonlyarg ( i ) |
148+ param .getLocation ( ) .getStartLine ( ) < id .getLocation ( ) .getStartLine ( )
149+ or
150+ param .getLocation ( ) .getStartLine ( ) = id .getLocation ( ) .getStartLine ( ) and
151+ param .getLocation ( ) .getStartColumn ( ) < id .getLocation ( ) .getStartColumn ( )
152+ )
153+ )
154+ )
122155 )
123156select id , kind , parent , newidx
0 commit comments