Deprecations cleanup: sequence -> asSequence

This commit is contained in:
Ilya Gorbunov
2015-06-25 20:25:31 +03:00
parent 765733b791
commit 5779b89ff0
12 changed files with 19 additions and 20 deletions
@@ -53,7 +53,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable(
callType: CallType,
containingDeclarationOrModule: DeclarationDescriptor
): Collection<CallableDescriptor> {
val sequence = receivers.sequence().flatMap { substituteExtensionIfCallable(it, callType, context, dataFlowInfo, containingDeclarationOrModule).sequence() }
val sequence = receivers.asSequence().flatMap { substituteExtensionIfCallable(it, callType, context, dataFlowInfo, containingDeclarationOrModule).asSequence() }
if (getTypeParameters().isEmpty()) { // optimization for non-generic callables
return sequence.firstOrNull()?.let { listOf(it) } ?: listOf()
}
@@ -81,7 +81,7 @@ public fun CallableDescriptor.substituteExtensionIfCallable(
if (!receiver.exists()) return listOf()
if (!callType.canCall(this)) return listOf()
var types = SmartCastUtils.getSmartCastVariants(receiver, bindingContext, containingDeclarationOrModule, dataFlowInfo).sequence()
var types = SmartCastUtils.getSmartCastVariants(receiver, bindingContext, containingDeclarationOrModule, dataFlowInfo).asSequence()
if (callType == CallType.SAFE) {
types = types.map { it.makeNotNullable() }
@@ -167,7 +167,7 @@ public class CheckPartialBodyResolveAction : AnAction() {
private fun allKotlinFiles(filesOrDirs: Array<VirtualFile>, project: Project): Sequence<JetFile> {
val manager = PsiManager.getInstance(project)
return allFiles(filesOrDirs)
.sequence()
.asSequence()
.map { manager.findFile(it) as? JetFile }
.filterNotNull()
}
@@ -153,7 +153,7 @@ public class FindImplicitNothingAction : AnAction() {
private fun allKotlinFiles(filesOrDirs: Array<VirtualFile>, project: Project): Sequence<JetFile> {
val manager = PsiManager.getInstance(project)
return allFiles(filesOrDirs)
.sequence()
.asSequence()
.map { manager.findFile(it) as? JetFile }
.filterNotNull()
}
@@ -106,11 +106,11 @@ private fun findPackagePartFileNamesForElement(elementAt: JetElement): List<Stri
JdkScope(project, libraryEntry as JdkOrderEntry)
}
val packagePartFiles = FilenameIndex.getAllFilenames(project).sequence().filter {
val packagePartFiles = FilenameIndex.getAllFilenames(project).asSequence().filter {
it.startsWith(packagePartNameWoHash) && it.endsWith(".class") &&
!it.substringAfter(packagePartNameWoHash).contains("\$")
}.flatMap {
FilenameIndex.getVirtualFilesByName(project, it, scope).sequence()
FilenameIndex.getVirtualFilesByName(project, it, scope).asSequence()
}.map {
val packageFqName = file.getPackageFqName()
if (packageFqName.isRoot()) {
@@ -225,12 +225,12 @@ public class JetPsiUnifier(
if (args1.size() != args2.size()) return UNMATCHED
if (rc1.getCall().getValueArguments().size() != args1.size() || rc2.getCall().getValueArguments().size() != args2.size()) return null
return (args1.sequence() zip args2.sequence()).fold(MATCHED) { s, p ->
return (args1.asSequence() zip args2.asSequence()).fold(MATCHED) { s, p ->
val (arg1, arg2) = p
s and when {
arg1 == arg2 -> MATCHED
arg1 == null || arg2 == null -> UNMATCHED
else -> (arg1.getArguments().sequence() zip arg2.getArguments().sequence()).fold(MATCHED) { s, p ->
else -> (arg1.getArguments().asSequence() zip arg2.getArguments().asSequence()).fold(MATCHED) { s, p ->
s and matchArguments(p.first, p.second)
}
}
@@ -737,7 +737,7 @@ public class JetPsiUnifier(
val patternElements = pattern.elements
if (targetElements.size() != patternElements.size()) return UNMATCHED
return (targetElements.sequence() zip patternElements.sequence()).fold(MATCHED) { s, p ->
return (targetElements.asSequence() zip patternElements.asSequence()).fold(MATCHED) { s, p ->
if (s != UNMATCHED) s and doUnify(p.first, p.second) else s
}
}