@@ -10,6 +10,10 @@ class XMLRecordedCall extends XMLElement {
1010
1111 XMLCall getXMLCall ( ) { result .getParent ( ) = this }
1212
13+ Function getPythonCallee ( ) { result = this .getXMLCallee ( ) .( XMLPythonCallee ) .getCallee ( ) }
14+
15+ Builtin getBuiltinCallee ( ) { result = this .getXMLCallee ( ) .( XMLExternalCallee ) .getCallee ( ) }
16+
1317 XMLCallee getXMLCallee ( ) { result .getParent ( ) = this }
1418
1519 /** Get a different `XMLRecordedCall` with the same result-set for `getCall`. */
@@ -26,7 +30,10 @@ class XMLRecordedCall extends XMLElement {
2630 }
2731
2832 override string toString ( ) {
29- result = this .getName ( ) + " (<..>/" + this .getXMLCall ( ) .get_filename_data ( ) .regexpCapture ( ".*/([^/]+)$" , 1 ) + ":" + this .getXMLCall ( ) .get_linenum_data ( ) + ")"
33+ result =
34+ this .getName ( ) + ": <..>/" +
35+ this .getXMLCall ( ) .get_filename_data ( ) .regexpCapture ( ".*/([^/]+)$" , 1 ) + ":" +
36+ this .getXMLCall ( ) .get_linenum_data ( )
3037 }
3138}
3239
@@ -80,8 +87,10 @@ class XMLPythonCallee extends XMLCallee {
8087 result .getLocation ( ) .hasLocationInfo ( this .get_filename_data ( ) , this .get_linenum_data ( ) , _, _, _)
8188 or
8289 // if function has decorator, the call will be recorded going to the first
83- result .getADecorator ( ) .getLocation ( ) .hasLocationInfo ( this .get_filename_data ( ) , this .get_linenum_data ( ) , _, _, _)
84-
90+ result
91+ .getADecorator ( )
92+ .getLocation ( )
93+ .hasLocationInfo ( this .get_filename_data ( ) , this .get_linenum_data ( ) , _, _, _)
8594 }
8695}
8796
@@ -127,9 +136,9 @@ class IdentifiedRecordedCall extends XMLRecordedCall {
127136 IdentifiedRecordedCall ( ) {
128137 strictcount ( this .getCall ( ) ) = 1 and
129138 (
130- strictcount ( this .getXMLCallee ( ) . ( XMLPythonCallee ) . getCallee ( ) ) = 1
139+ strictcount ( this .getPythonCallee ( ) ) = 1
131140 or
132- strictcount ( this .getXMLCallee ( ) . ( XMLExternalCallee ) . getCallee ( ) ) = 1
141+ strictcount ( this .getBuiltinCallee ( ) ) = 1
133142 )
134143 or
135144 // Handle case where the same function is called multiple times in one line, for
@@ -141,14 +150,26 @@ class IdentifiedRecordedCall extends XMLRecordedCall {
141150 // is not recorded, we woulld still mark the other two recorded calls as valid
142151 // (which is not following the rules above). + 1 to count `this` as well.
143152 strictcount ( this .getCall ( ) ) = strictcount ( this .getOtherWithSameSetOfCalls ( ) ) + 1 and
144- forex ( XMLRecordedCall rc |
145- rc = this .getOtherWithSameSetOfCalls ( )
146- |
147- unique( Function f | f = this .getXMLCallee ( ) .( XMLPythonCallee ) .getCallee ( ) ) =
148- unique( Function f | f = rc .getXMLCallee ( ) .( XMLPythonCallee ) .getCallee ( ) )
153+ forex ( XMLRecordedCall rc | rc = this .getOtherWithSameSetOfCalls ( ) |
154+ unique( Function f | f = this .getPythonCallee ( ) ) =
155+ unique( Function f | f = rc .getPythonCallee ( ) )
149156 or
150- unique( Builtin b | b = this .getXMLCallee ( ) .( XMLExternalCallee ) .getCallee ( ) ) =
151- unique( Builtin b | b = rc .getXMLCallee ( ) .( XMLExternalCallee ) .getCallee ( ) )
157+ unique( Builtin b | b = this .getBuiltinCallee ( ) ) =
158+ unique( Builtin b | b = rc .getBuiltinCallee ( ) )
159+ )
160+ }
161+
162+ override string toString ( ) {
163+ exists ( string callee_str |
164+ exists ( Function callee | callee = this .getPythonCallee ( ) |
165+ callee_str =
166+ callee .toString ( ) + " (<..>/" + callee .getLocation ( ) .getFile ( ) .getRelativePath ( ) + ":" +
167+ callee .getLocation ( ) .getStartLine ( ) + ")"
168+ )
169+ or
170+ callee_str = this .getBuiltinCallee ( ) .toString ( )
171+ |
172+ result = super .toString ( ) + " --> " + callee_str
152173 )
153174 }
154175}
0 commit comments