CreateExpectedFix: remove recursive call from findAndApplyExistingClasses
This commit is contained in:
@@ -164,14 +164,17 @@ class CreateExpectedClassFix(
|
|||||||
generateClassOrObject(project, true, element, checker)
|
generateClassOrObject(project, true, element, checker)
|
||||||
})
|
})
|
||||||
|
|
||||||
private tailrec fun TypeAccessibilityChecker.findAndApplyExistingClasses(elements: Collection<KtNamedDeclaration>): HashSet<String> {
|
private fun TypeAccessibilityChecker.findAndApplyExistingClasses(elements: Collection<KtNamedDeclaration>): HashSet<String> {
|
||||||
val classes = elements.filterIsInstance<KtClassOrObject>()
|
var classes = elements.filterIsInstance<KtClassOrObject>()
|
||||||
val existingNames = classes.mapNotNull { it.fqName?.asString() }.toHashSet()
|
while (true) {
|
||||||
existingFqNames = existingNames
|
val existingNames = classes.mapNotNull { it.fqName?.asString() }.toHashSet()
|
||||||
|
existingFqNames = existingNames
|
||||||
|
|
||||||
val newExistingClasses = classes.filter { isCorrectAndHaveNonPrivate(it) }
|
val newExistingClasses = classes.filter { isCorrectAndHaveNonPrivate(it) }
|
||||||
return if (classes.size == newExistingClasses.size) existingNames
|
if (classes.size == newExistingClasses.size) return existingNames
|
||||||
else findAndApplyExistingClasses(newExistingClasses)
|
|
||||||
|
classes = newExistingClasses
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun showUnknownTypesDialog(project: Project, declarationsWithNonExistentClasses: Collection<KtNamedDeclaration>): Boolean {
|
private fun showUnknownTypesDialog(project: Project, declarationsWithNonExistentClasses: Collection<KtNamedDeclaration>): Boolean {
|
||||||
|
|||||||
Reference in New Issue
Block a user