File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import java
2+
3+ private string jarName ( CompilationUnit cu ) {
4+ result = cu .getParentContainer ( ) .toString ( ) .regexpCapture ( ".*/(.*\\.jar)/?.*" , 1 )
5+ }
6+
7+ predicate isJavaRuntime ( Callable call ) {
8+ jarName ( call .getCompilationUnit ( ) ) = "rt.jar" or
9+ call .getCompilationUnit ( ) .getParentContainer ( ) .toString ( ) .substring ( 0 , 14 ) = "/modules/java."
10+ }
11+
12+ // TODO Is this heuristic too broad?
13+ predicate isInterestingAPI ( Callable call ) {
14+ call .getNumberOfParameters ( ) > 0 and
15+ not (
16+ call .getReturnType ( ) instanceof VoidType or
17+ call .getReturnType ( ) instanceof PrimitiveType or
18+ call .getReturnType ( ) instanceof BoxedType
19+ )
20+ }
Original file line number Diff line number Diff line change 1+ /**
2+ * @name JDK API Usage
3+ * @description A list of JDK APIs used in the source code.
4+ * @id java/telemetry/jdk-apis
5+ */
6+
7+ import java
8+ import APIUsage
9+
10+ from Callable call , CompilationUnit cu
11+ where
12+ cu = call .getCompilationUnit ( ) and
13+ isJavaRuntime ( call ) and
14+ isInterestingAPI ( call )
15+ select cu , call as API , count ( Call c | c .getCallee ( ) = call ) as calls order by calls desc
You can’t perform that action at this time.
0 commit comments