2
2
3
3
import java
4
4
5
+ /** Holds if the given package `p` is a test package. */
5
6
pragma [ nomagic]
6
7
private predicate isTestPackage ( Package p ) {
7
8
p .getName ( )
@@ -12,33 +13,35 @@ private predicate isTestPackage(Package p) {
12
13
"org.xmlunit%" , "org.testcontainers.%" , "org.opentest4j%" , "org.mockserver%" ,
13
14
"org.powermock%" , "org.skyscreamer.jsonassert%" , "org.rnorth.visibleassertions" ,
14
15
"org.openqa.selenium%" , "com.gargoylesoftware.htmlunit%" , "org.jboss.arquillian.testng%" ,
15
- "org.testng%" , "%.test%"
16
+ "org.testng%"
16
17
] )
17
18
}
18
19
19
20
/**
20
21
* A test library.
21
22
*/
22
- private class TestLibrary extends RefType {
23
+ class TestLibrary extends RefType {
23
24
TestLibrary ( ) { isTestPackage ( this .getPackage ( ) ) }
24
25
}
25
26
27
+ /** Holds if the given file is a test file. */
26
28
private predicate isInTestFile ( File file ) {
27
29
file .getAbsolutePath ( ) .matches ( "%src/test/%" ) or
28
30
file .getAbsolutePath ( ) .matches ( "%/guava-tests/%" ) or
29
31
file .getAbsolutePath ( ) .matches ( "%/guava-testlib/%" )
30
32
}
31
33
34
+ /** Holds if the given compilation unit's package is a JDK internal. */
32
35
private predicate isJdkInternal ( CompilationUnit cu ) {
33
36
cu .getPackage ( ) .getName ( ) .matches ( "org.graalvm%" ) or
34
- cu .getPackage ( ) .getName ( ) .matches ( "com.sun%" ) or // ! maybe don't exclude `sun` ones? see SensitiveApi models again.
37
+ cu .getPackage ( ) .getName ( ) .matches ( "com.sun%" ) or
35
38
cu .getPackage ( ) .getName ( ) .matches ( "sun%" ) or
36
39
cu .getPackage ( ) .getName ( ) .matches ( "jdk%" ) or
37
40
cu .getPackage ( ) .getName ( ) .matches ( "java2d%" ) or
38
41
cu .getPackage ( ) .getName ( ) .matches ( "build.tools%" ) or
39
42
cu .getPackage ( ) .getName ( ) .matches ( "propertiesparser%" ) or
40
43
cu .getPackage ( ) .getName ( ) .matches ( "org.jcp%" ) or
41
- cu .getPackage ( ) .getName ( ) .matches ( "org.w3c%" ) or // ! maybe don't exclude these?
44
+ cu .getPackage ( ) .getName ( ) .matches ( "org.w3c%" ) or
42
45
cu .getPackage ( ) .getName ( ) .matches ( "org.ietf.jgss%" ) or
43
46
cu .getPackage ( ) .getName ( ) .matches ( "org.xml.sax%" ) or
44
47
cu .getPackage ( ) .getName ( ) .matches ( "com.oracle%" ) or
@@ -48,18 +51,17 @@ private predicate isJdkInternal(CompilationUnit cu) {
48
51
cu .getPackage ( ) .getName ( ) = "transparentruler" or
49
52
cu .getPackage ( ) .getName ( ) = "genstubs" or
50
53
cu .getPackage ( ) .getName ( ) = "netscape.javascript" or
51
- cu .getPackage ( ) .getName ( ) = "" or
52
- cu .getPackage ( ) .getName ( ) .matches ( "%internal%" )
54
+ cu .getPackage ( ) .getName ( ) = ""
53
55
}
54
56
55
- /** Holds if the given callable is not worth modeling . */
57
+ /** Holds if the given callable is not interesting to model . */
56
58
private predicate isUninterestingForModels ( Callable c ) {
57
- c .getDeclaringType ( ) instanceof TestLibrary or
58
59
isInTestFile ( c .getCompilationUnit ( ) .getFile ( ) ) or
59
60
isJdkInternal ( c .getCompilationUnit ( ) ) or
60
61
c instanceof MainMethod or
61
62
c instanceof StaticInitializer or
62
63
exists ( FunctionalExpr funcExpr | c = funcExpr .asMethod ( ) ) or
64
+ c .getDeclaringType ( ) instanceof TestLibrary or
63
65
c .( Constructor ) .isParameterless ( )
64
66
}
65
67
0 commit comments