Code cleanup: convert flatMap { it } into flatten()

This commit is contained in:
Mikhail Glukhikh
2018-08-30 19:04:58 +03:00
parent dead2516c2
commit ad4da3d761
5 changed files with 5 additions and 5 deletions
@@ -270,7 +270,7 @@ class TowerResolver {
val candidatesGroups = if (useOrder) {
processor.process(towerData)
} else {
listOf(processor.process(towerData).flatMap { it })
listOf(processor.process(towerData).flatten())
}
for (candidatesGroup in candidatesGroups) {
@@ -116,7 +116,7 @@ class PartialBodyResolveFilter(
if (!smartCastPlaces.isEmpty()) {
//TODO: do we really need correct resolve for ALL smart cast places?
smartCastPlaces.values
.flatMap { it }
.flatten()
.forEach { statementMarks.mark(it, MarkLevel.NEED_REFERENCE_RESOLVE) }
updateNameFilter()
}
@@ -149,7 +149,7 @@ class ExpressionsOfTypeProcessor(
runReadAction {
val scopeElements = scopesToUsePlainSearch.values
.flatMap { it }
.flatten()
.filter { it.isValid }
.toTypedArray()
if (scopeElements.isNotEmpty()) {
@@ -128,7 +128,7 @@ class KotlinCopyPasteReferenceProcessor : CopyPastePostProcessor<KotlinReference
file.elementsInRange(it).filter { it is KtElement || it is KDocElement }
})
val allElementsToResolve = elementsByRange.values.flatMap { it }.flatMap { it.collectDescendantsOfType<KtElement>() }
val allElementsToResolve = elementsByRange.values.flatten().flatMap { it.collectDescendantsOfType<KtElement>() }
val bindingContext = file.getResolutionFacade().analyze(allElementsToResolve, BodyResolveMode.PARTIAL)
val result = ArrayList<KotlinReferenceData>()
@@ -157,7 +157,7 @@ class JavaToKotlinConverter(
if (usageProcessings.isEmpty()) return null
val map: Map<PsiElement, Collection<UsageProcessing>> = usageProcessings.values
.flatMap { it }
.flatten()
.filter { it.javaCodeProcessors.isNotEmpty() || it.kotlinCodeProcessors.isNotEmpty() }
.groupBy { it.targetElement }
if (map.isEmpty()) return null