22
33import java
44
5+ /** Holds if the given package `p` is a test package. */
56pragma [ nomagic]
67private predicate isTestPackage ( Package p ) {
78 p .getName ( )
@@ -12,33 +13,35 @@ private predicate isTestPackage(Package p) {
1213 "org.xmlunit%" , "org.testcontainers.%" , "org.opentest4j%" , "org.mockserver%" ,
1314 "org.powermock%" , "org.skyscreamer.jsonassert%" , "org.rnorth.visibleassertions" ,
1415 "org.openqa.selenium%" , "com.gargoylesoftware.htmlunit%" , "org.jboss.arquillian.testng%" ,
15- "org.testng%" , "%.test%"
16+ "org.testng%"
1617 ] )
1718}
1819
1920/**
2021 * A test library.
2122 */
22- private class TestLibrary extends RefType {
23+ class TestLibrary extends RefType {
2324 TestLibrary ( ) { isTestPackage ( this .getPackage ( ) ) }
2425}
2526
27+ /** Holds if the given file is a test file. */
2628private predicate isInTestFile ( File file ) {
2729 file .getAbsolutePath ( ) .matches ( "%src/test/%" ) or
2830 file .getAbsolutePath ( ) .matches ( "%/guava-tests/%" ) or
2931 file .getAbsolutePath ( ) .matches ( "%/guava-testlib/%" )
3032}
3133
34+ /** Holds if the given compilation unit's package is a JDK internal. */
3235private predicate isJdkInternal ( CompilationUnit cu ) {
3336 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
3538 cu .getPackage ( ) .getName ( ) .matches ( "sun%" ) or
3639 cu .getPackage ( ) .getName ( ) .matches ( "jdk%" ) or
3740 cu .getPackage ( ) .getName ( ) .matches ( "java2d%" ) or
3841 cu .getPackage ( ) .getName ( ) .matches ( "build.tools%" ) or
3942 cu .getPackage ( ) .getName ( ) .matches ( "propertiesparser%" ) or
4043 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
4245 cu .getPackage ( ) .getName ( ) .matches ( "org.ietf.jgss%" ) or
4346 cu .getPackage ( ) .getName ( ) .matches ( "org.xml.sax%" ) or
4447 cu .getPackage ( ) .getName ( ) .matches ( "com.oracle%" ) or
@@ -48,18 +51,17 @@ private predicate isJdkInternal(CompilationUnit cu) {
4851 cu .getPackage ( ) .getName ( ) = "transparentruler" or
4952 cu .getPackage ( ) .getName ( ) = "genstubs" or
5053 cu .getPackage ( ) .getName ( ) = "netscape.javascript" or
51- cu .getPackage ( ) .getName ( ) = "" or
52- cu .getPackage ( ) .getName ( ) .matches ( "%internal%" )
54+ cu .getPackage ( ) .getName ( ) = ""
5355}
5456
55- /** Holds if the given callable is not worth modeling . */
57+ /** Holds if the given callable is not interesting to model . */
5658private predicate isUninterestingForModels ( Callable c ) {
57- c .getDeclaringType ( ) instanceof TestLibrary or
5859 isInTestFile ( c .getCompilationUnit ( ) .getFile ( ) ) or
5960 isJdkInternal ( c .getCompilationUnit ( ) ) or
6061 c instanceof MainMethod or
6162 c instanceof StaticInitializer or
6263 exists ( FunctionalExpr funcExpr | c = funcExpr .asMethod ( ) ) or
64+ c .getDeclaringType ( ) instanceof TestLibrary or
6365 c .( Constructor ) .isParameterless ( )
6466}
6567
0 commit comments