Clean up code using the newly minted RedundantAsSequenceInspection

#KTIJ-31931

GitOrigin-RevId: d6de482f23d5c57dba23b2994ed65aaea94527ed
This commit is contained in:
Andrey Cherkasov
2025-04-06 20:09:54 +04:00
committed by intellij-monorepo-bot
parent 4d714d9033
commit 6346b08aa2
9 changed files with 9 additions and 9 deletions

View File

@@ -34,7 +34,7 @@ internal suspend fun generateClasspath(context: BuildContext): List<String> {
val excluded = excludedLibJars(context)
val existing = HashSet<Path>()
Files.newDirectoryStream(libDir).use { stream ->
stream.asSequence().filterTo(existing) { it.toString().endsWith(".jar") && !excluded.contains(it.fileName.toString()) }
stream.filterTo(existing) { it.toString().endsWith(".jar") && !excluded.contains(it.fileName.toString()) }
}
val result = computeAppClassPath(libDir, existing).map { libDir.relativize(it).toString() }
span.setAttribute(AttributeKey.stringArrayKey("result"), result)

View File

@@ -209,7 +209,7 @@ object FileTypeUsageCounterCollector : CounterUsagesCollector() {
return
}
val fileNameMatchers = fileTypeManager.getStandardMatchers(fileType)
fileNameMatchers.asSequence()
fileNameMatchers
.firstOrNull { it.acceptsCharSequence(file.getName()) }
?.let {
data.add(FILE_NAME_PATTERN_FIELD.with(it.getPresentableString()))

View File

@@ -63,7 +63,7 @@ class SeResultListModel: DefaultListModel<SeResultListRow>() {
private fun firstIndexOrNull(fullSearch: Boolean, predicate: (SeItemData) -> Boolean): Int? {
val startIndex = if (fullSearch || ignoreFreezing) 0 else frozenCount
return (startIndex until size).asSequence().firstOrNull { index ->
return (startIndex until size).firstOrNull { index ->
when (val row = getElementAt(index)) {
is SeResultListItemRow -> {
predicate(row.item)

View File

@@ -269,7 +269,7 @@ internal class WorkspaceMetaModelBuilder(
classSymbol.classKind == KaClassKind.ENUM_CLASS -> {
val enumEntries = classSymbol.staticMemberScope.callables.filterIsInstance<KaEnumEntrySymbol>().map { it.name.asString() }
ValueType.Enum<Any>(javaClassFqn, superTypesJavaFqns, enumEntries.toList(),
createProperties(classSymbol, knownTypes).asSequence().withoutEnumFields().toList())
createProperties(classSymbol, knownTypes).withoutEnumFields().toList())
}
classSymbol.modality == KaSymbolModality.SEALED && classSymbol is KaNamedClassSymbol -> {
val subclasses = classSymbol.sealedClassInheritors

View File

@@ -105,7 +105,7 @@ fun checkDeclarationNewNameConflicts(
if (symbol is KaValueParameterSymbol) {
val functionLikeSymbol = containingSymbol as KaFunctionSymbol
val locals = functionLikeSymbol.psi?.descendantsOfType<KtVariableDeclaration>()?.filter { it.nameAsName == newName }
?.mapNotNull { it.symbol }?.asSequence() ?: emptySequence()
?.mapNotNull { it.symbol } ?: emptySequence()
return functionLikeSymbol.valueParameters.filter { it.name == newName }.asSequence() + locals
}

View File

@@ -154,7 +154,7 @@ internal object FirKotlinUastConstantEvaluator {
if (operands.any { it is String } && operator != UastBinaryOperator.PLUS) {
return null
}
return operands.asSequence().reduceOrNull { opr1, opr2 ->
return operands.reduceOrNull { opr1, opr2 ->
if (opr1 is String || opr2 is String) {
return@reduceOrNull opr1.toString() + opr2.toString()
}

View File

@@ -439,7 +439,7 @@ internal val PythonAddInterpreterModel.existingSdks
get() = allInterpreters.value.filterIsInstance<ExistingSelectableInterpreter>().map { it.sdk }
internal fun PythonAddInterpreterModel.findInterpreter(path: String): PythonSelectableInterpreter? {
return allInterpreters.value.asSequence().find { it.homePath == path }
return allInterpreters.value.find { it.homePath == path }
}
internal suspend fun PythonAddInterpreterModel.detectCondaEnvironmentsOrError(errorSink: ErrorSink) {

View File

@@ -181,7 +181,7 @@ private suspend fun getPipFileLockRequirements(virtualFile: VirtualFile, package
.filterNot { (_, pkg) -> pkg.editable ?: false }
// TODO: Support requirements markers (PEP 496), currently any packages with markers are ignored due to PY-30803
.filter { (_, pkg) -> pkg.markers == null }
.flatMap { (name, pkg) -> packageManager.parseRequirements("$name${pkg.version ?: ""}") }.asSequence()
.flatMap { (name, pkg) -> packageManager.parseRequirements("$name${pkg.version ?: ""}") }
.toList()
val pipFileLock = parsePipFileLock(virtualFile).getOrNull() ?: return null

View File

@@ -21,7 +21,7 @@ interface UastCodeGenerationPlugin {
private val extensionPointName = ExtensionPointName<UastCodeGenerationPlugin>("org.jetbrains.uast.generate.uastCodeGenerationPlugin")
@JvmStatic
fun byLanguage(language: Language): UastCodeGenerationPlugin? = extensionPointName.extensionList.asSequence().firstOrNull { it.language == language }
fun byLanguage(language: Language): UastCodeGenerationPlugin? = extensionPointName.extensionList.firstOrNull { it.language == language }
}
/**