Deprecations cleanup: sequence -> asSequence
This commit is contained in:
@@ -30,7 +30,7 @@ public class CompositeBindingContext private constructor(
|
||||
private val delegates: List<BindingContext>
|
||||
) : BindingContext {
|
||||
override fun getType(expression: JetExpression): JetType? {
|
||||
return delegates.sequence().map { it.getType(expression) }.firstOrNull { it != null }
|
||||
return delegates.asSequence().map { it.getType(expression) }.firstOrNull { it != null }
|
||||
}
|
||||
|
||||
companion object {
|
||||
@@ -42,7 +42,7 @@ public class CompositeBindingContext private constructor(
|
||||
}
|
||||
|
||||
override fun <K, V> get(slice: ReadOnlySlice<K, V>?, key: K?): V? {
|
||||
return delegates.sequence().map { it[slice, key] }.firstOrNull { it != null }
|
||||
return delegates.asSequence().map { it[slice, key] }.firstOrNull { it != null }
|
||||
}
|
||||
|
||||
override fun <K, V> getKeys(slice: WritableSlice<K, V>?): Collection<K> {
|
||||
@@ -65,8 +65,7 @@ public class CompositeBindingContext private constructor(
|
||||
) : Diagnostics {
|
||||
|
||||
override fun iterator(): Iterator<Diagnostic> {
|
||||
val emptyStream = listOf<Diagnostic>().sequence()
|
||||
return delegates.fold(emptyStream, { r, t -> r + t.sequence() }).iterator()
|
||||
return delegates.fold(emptySequence<Diagnostic>(), { r, t -> r + t.asSequence() }).iterator()
|
||||
}
|
||||
|
||||
override val modificationTracker = object : ModificationTracker {
|
||||
|
||||
+1
-1
@@ -77,7 +77,7 @@ public class LazyAnnotations(
|
||||
|
||||
override fun findExternalAnnotation(fqName: FqName) = null
|
||||
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = annotationEntries.sequence().map(annotation).iterator()
|
||||
override fun iterator(): Iterator<AnnotationDescriptor> = annotationEntries.asSequence().map(annotation).iterator()
|
||||
|
||||
override fun forceResolveAllContents() {
|
||||
// To resolve all entries
|
||||
|
||||
@@ -53,7 +53,7 @@ public object InlineTestUtil {
|
||||
|
||||
|
||||
val skipParameterChecking =
|
||||
sourceFiles.sequence().filter {
|
||||
sourceFiles.asSequence().filter {
|
||||
InTextDirectivesUtils.isDirectiveDefined(it.getText(), "NO_CHECK_LAMBDA_INLINING")
|
||||
}.any()
|
||||
|
||||
|
||||
+2
-2
@@ -39,7 +39,7 @@ class LazyJavaAnnotations(
|
||||
c.externalAnnotationResolver.findExternalAnnotation(annotationOwner, fqName)?.let(annotationDescriptors)
|
||||
|
||||
override fun iterator() =
|
||||
annotationOwner.getAnnotations().sequence().map(annotationDescriptors).filterNotNull().iterator()
|
||||
annotationOwner.getAnnotations().asSequence().map(annotationDescriptors).filterNotNull().iterator()
|
||||
|
||||
override fun isEmpty() = !iterator().hasNext()
|
||||
}
|
||||
@@ -56,7 +56,7 @@ class FilteredAnnotations(
|
||||
if (fqNameFilter(fqName)) delegate.findExternalAnnotation(fqName)
|
||||
else null
|
||||
|
||||
override fun iterator() = delegate.sequence()
|
||||
override fun iterator() = delegate.asSequence()
|
||||
.filter { annotation ->
|
||||
val descriptor = annotation.getType().getConstructor().getDeclarationDescriptor()
|
||||
descriptor != null && DescriptorUtils.getFqName(descriptor).let { fqName ->
|
||||
|
||||
@@ -80,7 +80,7 @@ class KClassImpl<T>(override val jClass: Class<T>) : KCallableContainerImpl(), K
|
||||
}
|
||||
|
||||
private fun <P : KProperty<*>> getProperties(extension: Boolean, declared: Boolean, create: (PropertyDescriptor) -> P): Collection<P> =
|
||||
scope.getAllDescriptors().sequence()
|
||||
scope.getAllDescriptors().asSequence()
|
||||
.filterIsInstance<PropertyDescriptor>()
|
||||
.filter { descriptor ->
|
||||
(descriptor.getExtensionReceiverParameter() != null) == extension &&
|
||||
|
||||
@@ -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() }
|
||||
|
||||
+1
-1
@@ -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()
|
||||
}
|
||||
|
||||
+2
-2
@@ -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
|
||||
}
|
||||
}
|
||||
|
||||
@@ -183,7 +183,7 @@ private fun RegExp.findNext(input: String, from: Int): MatchResult? {
|
||||
override fun contains(o: Any?): Boolean = this.any { it == o }
|
||||
override fun containsAll(c: Collection<Any?>): Boolean = c.all({contains(it)})
|
||||
|
||||
override fun iterator(): Iterator<MatchGroup?> = indices.sequence().map { this[it] }.iterator()
|
||||
override fun iterator(): Iterator<MatchGroup?> = indices.asSequence().map { this[it] }.iterator()
|
||||
|
||||
override fun get(index: Int): MatchGroup? = match[index]?.let { MatchGroup(it) }
|
||||
}
|
||||
|
||||
@@ -234,7 +234,7 @@ private fun Matcher.findNext(from: Int): MatchResult? {
|
||||
override fun contains(o: Any?): Boolean = o is MatchGroup? && this.any({ it == o })
|
||||
override fun containsAll(c: Collection<Any?>): Boolean = c.all({contains(it)})
|
||||
|
||||
override fun iterator(): Iterator<MatchGroup?> = indices.sequence().map { this[it] }.iterator()
|
||||
override fun iterator(): Iterator<MatchGroup?> = indices.asSequence().map { this[it] }.iterator()
|
||||
override fun get(index: Int): MatchGroup? {
|
||||
val range = matchResult.range(index)
|
||||
return if (range.start >= 0)
|
||||
|
||||
Reference in New Issue
Block a user