in core/src/main/java/com/facebook/ktfmt/format/RedundantImportDetector.kt [161:176]
fun getRedundantImportElements(): List<PsiElement> {
if (!enabled) return emptyList()
val redundantImports = mutableListOf<PsiElement>()
// Collect unused imports
for (import in importCleanUpCandidates) {
val isUnused = import.aliasName !in usedReferences && import.identifier !in usedReferences
val isFromSamePackage = import.importedFqName?.parent() == thisPackage && import.alias == null
if (isUnused || isFromSamePackage) {
redundantImports += import
}
}
return redundantImports
}