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 {
23
23
}
24
24
25
25
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
+ }
26
34
}
27
35
28
36
private class TestLibrary extends RefType {
Original file line number Diff line number Diff line change 1
1
/**
2
2
* @name External libraries
3
3
* @description A list of external libraries used in the code
4
- * @kind diagnostic
4
+ * @kind metric
5
+ * @metricType callable
5
6
* @id java/telemetry/external-libs
6
7
*/
7
8
8
9
import java
9
10
import ExternalAPI
10
11
11
- from int Usages , JarFile jar
12
+ from int Usages , string jarname
12
13
where
13
- jar = any ( ExternalAPI api ) .getCompilationUnit ( ) . getParentContainer * ( ) and
14
+ jarname = any ( ExternalAPI api ) .jarContainer ( ) and
14
15
Usages =
15
16
strictcount ( Call c , ExternalAPI a |
16
17
c .getCallee ( ) = a and
17
18
not c .getFile ( ) instanceof GeneratedFile and
18
- a .getCompilationUnit ( ) . getParentContainer * ( ) = jar and
19
+ a .jarContainer ( ) = jarname and
19
20
not a .isTestLibrary ( )
20
21
)
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