Compiler&plugin deprecations cleanup: replace streams with sequences.
This commit is contained in:
+4
-4
@@ -28,7 +28,7 @@ import org.jetbrains.kotlin.utils.addIfNotNull
|
||||
import org.jetbrains.kotlin.descriptors.CallableMemberDescriptor.Kind.*
|
||||
import java.util.*
|
||||
import org.jetbrains.kotlin.descriptors.*
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.streamOfLazyValues
|
||||
import org.jetbrains.kotlin.utils.addToStdlib.sequenceOfLazyValues
|
||||
|
||||
public object DescriptorToSourceUtilsIde {
|
||||
// Returns PSI element for descriptor. If there are many relevant elements (e.g. it is fake override
|
||||
@@ -45,12 +45,12 @@ public object DescriptorToSourceUtilsIde {
|
||||
return result.filter { element -> result.none { element != it && it.getNavigationElement() == element } }
|
||||
}
|
||||
|
||||
private fun getDeclarationsStream(project: Project, targetDescriptor: DeclarationDescriptor): Stream<PsiElement> {
|
||||
val effectiveReferencedDescriptors = DescriptorToSourceUtils.getEffectiveReferencedDescriptors(targetDescriptor).stream()
|
||||
private fun getDeclarationsStream(project: Project, targetDescriptor: DeclarationDescriptor): Sequence<PsiElement> {
|
||||
val effectiveReferencedDescriptors = DescriptorToSourceUtils.getEffectiveReferencedDescriptors(targetDescriptor).asSequence()
|
||||
return effectiveReferencedDescriptors.flatMap { effectiveReferenced ->
|
||||
// References in library sources should be resolved to corresponding decompiled declarations,
|
||||
// therefore we put both source declaration and decompiled declaration to stream, and afterwards we filter it in getAllDeclarations
|
||||
streamOfLazyValues(
|
||||
sequenceOfLazyValues(
|
||||
{ DescriptorToSourceUtils.getSourceFromDescriptor(effectiveReferenced) },
|
||||
{ findBuiltinDeclaration(project, effectiveReferenced) ?: DecompiledNavigationUtils.getDeclarationFromDecompiledClassFile(project, effectiveReferenced) }
|
||||
)
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ class KotlinOverrideTreeStructure(project: Project, val element: PsiElement) : H
|
||||
}
|
||||
|
||||
return javaTreeStructures
|
||||
.stream()
|
||||
.asSequence()
|
||||
.map (::buildChildrenByTreeStructure)
|
||||
.reduce { a, b -> ContainerUtil.union(a.toSet(), b.toSet()).toTypedArray() }
|
||||
}
|
||||
|
||||
+2
-2
@@ -203,7 +203,7 @@ fun ExtractableCodeDescriptor.findDuplicates(): List<DuplicateInfo> {
|
||||
return extractionData
|
||||
.originalRange
|
||||
.match(scopeElement, unifier)
|
||||
.stream()
|
||||
.asSequence()
|
||||
.filter { !(it.range.getTextRange() intersects originalTextRange) }
|
||||
.map { match ->
|
||||
val controlFlow = getControlFlowIfMatched(match)
|
||||
@@ -248,7 +248,7 @@ private fun makeCall(
|
||||
else -> calleeName
|
||||
}
|
||||
|
||||
val anchorInBlock = stream(anchor) { it.getParent() }.firstOrNull { it.getParent() is JetBlockExpression }
|
||||
val anchorInBlock = sequence(anchor) { it.getParent() }.firstOrNull { it.getParent() is JetBlockExpression }
|
||||
val block = (anchorInBlock?.getParent() as? JetBlockExpression) ?: anchorParent
|
||||
|
||||
val psiFactory = JetPsiFactory(anchor.getProject())
|
||||
|
||||
+4
-4
@@ -107,7 +107,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
return searchInfo
|
||||
}
|
||||
|
||||
fun findUsagesByJavaProcessor(elements: Stream<PsiElement>, insideDeleted: Condition<PsiElement>): Condition<PsiElement> =
|
||||
fun findUsagesByJavaProcessor(elements: Sequence<PsiElement>, insideDeleted: Condition<PsiElement>): Condition<PsiElement> =
|
||||
elements
|
||||
.map { element -> findUsagesByJavaProcessor(element, true)?.getInsideDeletedCondition() }
|
||||
.filterNotNull()
|
||||
@@ -116,7 +116,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
fun findUsagesByJavaProcessor(jetDeclaration: JetDeclaration): NonCodeUsageSearchInfo {
|
||||
return NonCodeUsageSearchInfo(
|
||||
findUsagesByJavaProcessor(
|
||||
jetDeclaration.toLightElements().stream(),
|
||||
jetDeclaration.toLightElements().asSequence(),
|
||||
getIgnoranceCondition()
|
||||
),
|
||||
jetDeclaration
|
||||
@@ -125,7 +125,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
|
||||
fun findKotlinDeclarationUsages(declaration: JetDeclaration): NonCodeUsageSearchInfo {
|
||||
ReferencesSearch.search(declaration, declaration.getUseScope())
|
||||
.stream()
|
||||
.asSequence()
|
||||
.filterNot { reference -> getIgnoranceCondition().value(reference.getElement()) }
|
||||
.mapTo(usages) { reference ->
|
||||
reference.getElement().getNonStrictParentOfType<JetImportDirective>()?.let { importDirective ->
|
||||
@@ -231,7 +231,7 @@ public class KotlinSafeDeleteProcessor : JavaSafeDeleteProcessor() {
|
||||
if (declarationDescriptor !is CallableMemberDescriptor) return null
|
||||
|
||||
return declarationDescriptor.getOverriddenDescriptors()
|
||||
.stream()
|
||||
.asSequence()
|
||||
.filter { overridenDescriptor -> overridenDescriptor.getModality() == Modality.ABSTRACT }
|
||||
.mapTo(ArrayList<String>()) { overridenDescriptor ->
|
||||
JetBundle.message(
|
||||
|
||||
@@ -56,7 +56,7 @@ fun PsiElement.removeOverrideModifier() {
|
||||
fun PsiMethod.cleanUpOverrides() {
|
||||
val superMethods = findSuperMethods(true)
|
||||
for (overridingMethod in OverridingMethodsSearch.search(this, true).findAll()) {
|
||||
val currentSuperMethods = overridingMethod.findSuperMethods(true).stream() + superMethods.stream()
|
||||
val currentSuperMethods = overridingMethod.findSuperMethods(true).asSequence() + superMethods.asSequence()
|
||||
if (currentSuperMethods.all { superMethod -> superMethod.unwrapped == unwrapped }) {
|
||||
overridingMethod.unwrapped?.removeOverrideModifier()
|
||||
}
|
||||
|
||||
+1
-1
@@ -46,7 +46,7 @@ public open class KotlinDirectInheritorsSearcher() : QueryExecutorBase<PsiClass,
|
||||
|
||||
runReadAction {
|
||||
val noLibrarySourceScope = JetSourceFilterScope.kotlinSourceAndClassFiles(scope, baseClass.getProject())
|
||||
JetSuperClassIndex.getInstance().get(name, baseClass.getProject(), noLibrarySourceScope).stream()
|
||||
JetSuperClassIndex.getInstance().get(name, baseClass.getProject(), noLibrarySourceScope).asSequence()
|
||||
.map { candidate -> JetSourceNavigationHelper.getOriginalPsiClassOrCreateLightClass(candidate)}
|
||||
.filterNotNull()
|
||||
.filter { candidate -> candidate.isInheritor(baseClass, false) }
|
||||
|
||||
Reference in New Issue
Block a user