int nPackageEntries= fPackageEntries.size(); // all type containers to be star imported final HashSet starImportPackages= new HashSet(nPackageEntries); // all simple type names referenced in a star-imported package, annottaed with the container final HashMap typeReferences= new HashMap(); // iterate the internal structure of the import rewrite for (int i= 0; i < nPackageEntries; i++) { PackageEntry pack= (PackageEntry) fPackageEntries.get(i); if (!pack.isStatic() && pack.hasStarImport(fImportOnDemandThreshold, null)) { starImportPackages.add(pack.getName()); for (int k= 0; k < pack.getNumberOfImports(); k++) { ImportDeclEntry curr= pack.getImportAt(k); if (!curr.isOnDemand() && !curr.isComment()) { typeReferences.put(curr.getSimpleName(), pack.getName()); } } } } if (starImportPackages.isEmpty()) { return null; } starImportPackages.add(fCompilationUnit.getParent().getElementName()); starImportPackages.add(JAVA_LANG); // resulting simple names that need a explicit import final HashSet onDemandConflicts= new HashSet(); IJavaSearchScope scope= SearchEngine.createJavaSearchScope(new IJavaElement[] { fCompilationUnit.getJavaProject() }); ITypeNameRequestor requestor= new ITypeNameRequestor() { public void acceptClass(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { processType(packageName, simpleTypeName, enclosingTypeNames); } public void acceptInterface(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames, String path) { processType(packageName, simpleTypeName, enclosingTypeNames); } private String getTypeContainerName(char[] packageName, char[][] enclosingTypeNames) { StringBuffer buf= new StringBuffer(); buf.append(packageName); for (int i= 0; i < enclosingTypeNames.length; i++) { if (buf.length() > 0) buf.append('.'); buf.append(enclosingTypeNames[i]); } return buf.toString(); } private void processType(char[] packageName, char[] simpleTypeName, char[][] enclosingTypeNames) { String name= new String(simpleTypeName); String knownContainer= (String) typeReferences.get(name); if (knownContainer != null) { String containerName= getTypeContainerName(packageName, enclosingTypeNames); if (starImportPackages.contains(containerName) && !knownContainer.equals(containerName)) { onDemandConflicts.add(name); } } } }; new SearchEngine().searchAllTypeNames(null, null, SearchPattern.R_PATTERN_MATCH, IJavaSearchConstants.TYPE, scope, requestor, IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH, monitor);