@@ -26,27 +26,21 @@ class MainFunction extends MainLikeFunction {
26
26
* such functions, however, they have certain features that can be used for
27
27
* identification. This can be refined based on experiments/real-world use.
28
28
*/
29
- class GTestFunction extends MainLikeFunction {
30
- GTestFunction ( ) {
29
+ class GoogleTestFunction extends MainLikeFunction {
30
+ GoogleTestFunction ( ) {
31
31
// A GoogleTest function is named "TestBody" and
32
32
this .hasName ( "TestBody" ) and
33
- // is enclosed by a class that inherits from a base class
34
- this .getEnclosingAccessHolder ( ) instanceof Class and
33
+ // it's parent class inherits a base class
35
34
exists ( Class base |
36
- base = this .getEnclosingAccessHolder ( ) .( Class ) .getABaseClass ( ) and
35
+ base = this .getEnclosingAccessHolder ( ) .( Class ) .getABaseClass + ( ) and
36
+ // with a name "Test" inside a namespace called "testing"
37
37
(
38
- // called "Test" or
39
- exists ( Class c | base .getABaseClass ( ) = c and c .hasName ( "Test" ) )
40
- or
41
- // defined under a namespace called "testing" or
42
- exists ( Namespace n | n = base .getNamespace ( ) | n .hasName ( "testing" ) )
43
- or
44
- // is templatized by a parameter called "gtest_TypeParam_"
45
- exists ( TemplateParameter tp |
46
- tp = base .getATemplateArgument ( ) and
47
- tp .hasName ( "gtest_TypeParam_" )
48
- )
38
+ base .hasName ( "Test" ) and
39
+ base .getNamespace ( ) .hasName ( "testing" )
49
40
)
41
+ or
42
+ // or at a location in a file called "gtest.h".
43
+ base .getDefinitionLocation ( ) .getFile ( ) .getBaseName ( ) = "gtest.h"
50
44
)
51
45
}
52
46
}
0 commit comments