File tree Expand file tree Collapse file tree 1 file changed +18
-2
lines changed
java/ql/src/utils/stub-generator Expand file tree Collapse file tree 1 file changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -279,7 +279,22 @@ private string stubQualifier(RefType t) {
279
279
exists ( RefType et | et = t .( NestedType ) .getEnclosingType ( ) .getSourceDeclaration ( ) |
280
280
result = stubQualifier ( et ) + et .getName ( ) + "."
281
281
)
282
- else result = ""
282
+ else
283
+ if needsPackageName ( t )
284
+ then result = t .getPackage ( ) .getName ( ) + "."
285
+ else result = ""
286
+ }
287
+
288
+ /**
289
+ * Holds if `t` may clash with another type of the same name, so should be referred to using the fully qualified name
290
+ */
291
+ private predicate needsPackageName ( RefType t ) {
292
+ exists ( GeneratedTopLevel top , RefType other |
293
+ t .getSourceDeclaration ( ) = [ getAReferencedType ( top ) , top ] .getSourceDeclaration ( ) and
294
+ other .getSourceDeclaration ( ) = [ getAReferencedType ( top ) , top ] .getSourceDeclaration ( ) and
295
+ t .getName ( ) = other .getName ( ) and
296
+ t != other
297
+ )
283
298
}
284
299
285
300
language [ monotonicAggregates]
@@ -503,7 +518,8 @@ class GeneratedTopLevel extends TopLevelType instanceof GeneratedType {
503
518
GeneratedTopLevel ( ) { this = this .getSourceDeclaration ( ) }
504
519
505
520
private TopLevelType getAnImportedType ( ) {
506
- result = getAReferencedType ( this ) .getSourceDeclaration ( )
521
+ result = getAReferencedType ( this ) .getSourceDeclaration ( ) and
522
+ not needsPackageName ( result ) // use the fully qualified name rather than importing it if it may cause name clashes
507
523
}
508
524
509
525
private string stubAnImport ( ) {
You can’t perform that action at this time.
0 commit comments