File tree Expand file tree Collapse file tree 3 files changed +36
-1
lines changed
Expand file tree Collapse file tree 3 files changed +36
-1
lines changed Original file line number Diff line number Diff line change @@ -18,10 +18,30 @@ class UsedInSource extends GeneratedDeclaration {
1818 this = any ( Expr e | e .getEnclosingCallable ( ) .fromSource ( ) ) .getType ( )
1919 or
2020 this = any ( RefType t | t .fromSource ( ) )
21+ or
22+ this = any ( TypeAccess ta | ta .fromSource ( ) )
2123 )
2224 }
2325}
2426
2527from GeneratedTopLevel t
2628where not t .fromSource ( )
2729select 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
Original file line number Diff line number Diff line change @@ -128,6 +128,10 @@ private class IndirectType extends GeneratedType {
128128 this = getAContainedType ( t .getAGeneratedType ( ) ) .( RefType ) .getSourceDeclaration ( )
129129 )
130130 or
131+ this .getSourceDeclaration ( ) instanceof GeneratedType
132+ or
133+ this = any ( GeneratedType t ) .getSourceDeclaration ( )
134+ or
131135 exists ( GeneratedType t | this = t .( BoundedType ) .getATypeBound ( ) .getType ( ) )
132136 or
133137 exists ( GeneratedDeclaration decl |
Original file line number Diff line number Diff line change @@ -120,10 +120,21 @@ def run(cmd):
120120with open (outputJsonFile ) as f :
121121 results = json .load (f )
122122
123- if not '#select' in results or not 'tuples' in results ['#select' ]:
123+ try :
124+ results ['#select' ]['tuples' ]
125+ results ['noGeneratedStubs' ]['tuples' ]
126+ results ['multipleGeneratedStubs' ]['tuples' ]
127+ except ValueError :
124128 print ('Unexpected JSON output - no tuples found' )
125129 exit (1 )
126130
131+ for (typ ,) in results ['noGeneratedStubs' ]['tuples' ]:
132+ print (f"WARNING: No stubs generated for { typ } . This is probably a bug." )
133+
134+ for (typ ,) in results ['multipleGeneratedStubs' ]['tuples' ]:
135+ print (
136+ f"WARNING: Multiple stubs generated for { typ } . This is probably a bug. One will be chosen arbitrarily." )
137+
127138for (typ , stub ) in results ['#select' ]['tuples' ]:
128139 stubFile = os .path .join (stubDir , typ .replace ("." , "/" ) + ".java" )
129140 os .makedirs (os .path .dirname (stubFile ), exist_ok = True )
You can’t perform that action at this time.
0 commit comments