File tree Expand file tree Collapse file tree 2 files changed +14
-5
lines changed
Expand file tree Collapse file tree 2 files changed +14
-5
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,14 @@ class ExternalAPI extends Callable {
2323 }
2424
2525 predicate isSupported ( ) { not supportKind ( this ) = "?" }
26+
27+ string jarContainer ( ) {
28+ result = containerAsJar ( any ( ExternalAPI api ) .getCompilationUnit ( ) .getParentContainer * ( ) )
29+ }
30+
31+ private string containerAsJar ( Container container ) {
32+ if container instanceof JarFile then result = container .getBaseName ( ) else result = "rt.jar"
33+ }
2634}
2735
2836private class TestLibrary extends RefType {
Original file line number Diff line number Diff line change 11/**
22 * @name External libraries
33 * @description A list of external libraries used in the code
4- * @kind diagnostic
4+ * @kind metric
5+ * @metricType callable
56 * @id java/telemetry/external-libs
67 */
78
89import java
910import ExternalAPI
1011
11- from int Usages , JarFile jar
12+ from int Usages , string jarname
1213where
13- jar = any ( ExternalAPI api ) .getCompilationUnit ( ) . getParentContainer * ( ) and
14+ jarname = any ( ExternalAPI api ) .jarContainer ( ) and
1415 Usages =
1516 strictcount ( Call c , ExternalAPI a |
1617 c .getCallee ( ) = a and
1718 not c .getFile ( ) instanceof GeneratedFile and
18- a .getCompilationUnit ( ) . getParentContainer * ( ) = jar and
19+ a .jarContainer ( ) = jarname and
1920 not a .isTestLibrary ( )
2021 )
21- select jar . getFile ( ) . getBaseName ( ) , Usages order by Usages desc
22+ select jarname , Usages order by Usages desc
You can’t perform that action at this time.
0 commit comments