public Set < Class < ? > > findReferencedTypes ( String typeName ) { Set < Class < ? > > referencedTypes = new HashSet <> ( ) ; // use the cached version if possible if ( referencedTypesCache . containsKey ( typeName ) ) { return referencedTypesCache . get ( typeName ) ; } try { CtClass cc = classPool . get ( typeName ) ; for ( Object referencedType : cc . getRefClasses ( ) ) { String referencedTypeName = ( String ) referencedType ; if ( ! isExcluded ( referencedTypeName ) ) { try { referencedTypes . add ( loadClass ( referencedTypeName ) ) ; } catch ( Throwable t ) { log . debug ( "Could not find " + referencedTypeName + " ... ignoring." ) ; } } } // remove the type itself referencedTypes . remove ( loadClass ( typeName ) ) ; } catch ( Exception e ) { log . debug ( "Error finding referenced types for " + typeName + " ... ignoring." ) ; // since there was an error, we can't find the set of referenced types from it, so... referencedTypesCache . put ( typeName , new HashSet <> ( ) ) ; } // cache for the next time referencedTypesCache . put ( typeName , referencedTypes ) ; return referencedTypes ; }
Finds the set of types referenced by the specified type .