Skip to content

Commit 7a27043

Browse files
authored
Merge pull request github#5943 from joefarebrother/java-stub
[Java] Add stubbing script
2 parents 3f72a1a + 7462180 commit 7a27043

File tree

3 files changed

+703
-0
lines changed

3 files changed

+703
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/**
2+
* Tool to generate java stubs from a qltest snapshot.
3+
*
4+
* It finds all declarations used in the source code,
5+
* and generates minimal java stubs containing those declarations
6+
* and their dependencies.
7+
*/
8+
9+
import java
10+
import Stubs
11+
12+
/** Declarations used by source code. */
13+
class UsedInSource extends GeneratedDeclaration {
14+
UsedInSource() {
15+
(
16+
this = any(Variable v | v.fromSource()).getType()
17+
or
18+
this = any(Expr e | e.getEnclosingCallable().fromSource()).getType()
19+
or
20+
this = any(RefType t | t.fromSource())
21+
or
22+
this = any(TypeAccess ta | ta.fromSource())
23+
)
24+
}
25+
}
26+
27+
from GeneratedTopLevel t
28+
where not t.fromSource()
29+
select t.getQualifiedName(), t.stubFile()
30+
31+
module Consistency {
32+
query predicate noGeneratedStubs(string s) {
33+
exists(GeneratedTopLevel t | s = t.getQualifiedName() |
34+
not t.fromSource() and
35+
not exists(t.stubFile())
36+
)
37+
}
38+
39+
query predicate multipleGeneratedStubs(string s) {
40+
exists(GeneratedTopLevel t | s = t.getQualifiedName() |
41+
not t.fromSource() and
42+
strictcount(t.stubFile()) > 1
43+
)
44+
}
45+
}
46+
47+
import Consistency

0 commit comments

Comments
 (0)