Replace reverse with reversed or asReversed.
This commit is contained in:
+1
-1
@@ -33,7 +33,7 @@ public class RedundantGotoMethodTransformer : MethodTransformer() {
|
||||
val insnsToRemove = arrayListOf<AbstractInsnNode>()
|
||||
|
||||
val currentLabels = hashSetOf<LabelNode>()
|
||||
for (insn in insns.reverse()) {
|
||||
for (insn in insns.reversed()) {
|
||||
if (insn.isMeaningful) {
|
||||
if (insn.getOpcode() == Opcodes.GOTO && (insn as JumpInsnNode).label in currentLabels) {
|
||||
insnsToRemove.add(insn)
|
||||
|
||||
+1
-1
@@ -111,7 +111,7 @@ fun generateLoadInstructions(methodNode: MethodNode, location: AbstractInsnNode,
|
||||
|
||||
fun generateStoreInstructions(methodNode: MethodNode, location: AbstractInsnNode, savedStackDescriptor: SavedStackDescriptor) {
|
||||
var localVarIndex = savedStackDescriptor.firstUnusedLocalVarIndex
|
||||
for (value in savedStackDescriptor.savedValues.reverse()) {
|
||||
for (value in savedStackDescriptor.savedValues.asReversed()) {
|
||||
localVarIndex -= value.getSize()
|
||||
methodNode.instructions.insertBefore(location,
|
||||
VarInsnNode(value.getType().getOpcode(Opcodes.ISTORE), localVarIndex))
|
||||
|
||||
@@ -45,7 +45,7 @@ public fun topologicalSort<T>(items: Iterable<T>, dependencies: (T) -> Iterable<
|
||||
for (item in items)
|
||||
DfsVisit(item)
|
||||
|
||||
return result.reverse()
|
||||
return result.reversed()
|
||||
}
|
||||
|
||||
public class CycleInTopoSortException : Exception()
|
||||
@@ -312,7 +312,7 @@ public class CallCompleter(
|
||||
}
|
||||
|
||||
var shouldBeMadeNullable: Boolean = false
|
||||
expressions.reverse().forEach { expression ->
|
||||
expressions.asReversed().forEach { expression ->
|
||||
if (!(expression is JetParenthesizedExpression || expression is JetLabeledExpression || expression is JetAnnotatedExpression)) {
|
||||
shouldBeMadeNullable = hasNecessarySafeCall(expression, trace)
|
||||
}
|
||||
|
||||
@@ -135,7 +135,7 @@ internal class DescriptorRendererImpl(
|
||||
}
|
||||
while (current is ClassDescriptor)
|
||||
|
||||
return renderFqName(qualifiedNameElements.reverse())
|
||||
return renderFqName(qualifiedNameElements.asReversed())
|
||||
}
|
||||
|
||||
NameShortness.FULLY_QUALIFIED -> return renderFqName(DescriptorUtils.getFqName(klass))
|
||||
|
||||
@@ -68,7 +68,7 @@ public inline fun <reified T : Any> Iterable<*>.lastIsInstanceOrNull(): T? {
|
||||
}
|
||||
|
||||
else -> {
|
||||
return reverse().firstIsInstanceOrNull<T>()
|
||||
return reversed().firstIsInstanceOrNull<T>()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+2
-2
@@ -193,7 +193,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
||||
if (tokenType in declarationKeywords) {
|
||||
val balance = ltCount - gtCount
|
||||
if (balance < 0) return null
|
||||
builder.append(token.getText()!!.reverse())
|
||||
builder.append(token.getText()!!.reversed())
|
||||
builder.reverse()
|
||||
|
||||
var tail = "X" + ">".repeat(balance) + ".f"
|
||||
@@ -212,7 +212,7 @@ public class KotlinCompletionContributor : CompletionContributor() {
|
||||
if (tokenType !in declarationTokens) return null
|
||||
if (tokenType == JetTokens.LT) ltCount++
|
||||
if (tokenType == JetTokens.GT) gtCount++
|
||||
builder.append(token.getText()!!.reverse())
|
||||
builder.append(token.getText()!!.reversed())
|
||||
token = PsiTreeUtil.prevLeaf(token) ?: return null
|
||||
}
|
||||
}
|
||||
|
||||
@@ -340,7 +340,7 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB
|
||||
for (leaf in lineBreakElement.prevLeafs) {
|
||||
var psiElement = findRestored(leaf)
|
||||
if (psiElement != null) {
|
||||
psiElement = skipTokensForward(psiElement, tokensToMatch.reverse())
|
||||
psiElement = skipTokensForward(psiElement, tokensToMatch.asReversed())
|
||||
psiElement?.restoreLineBreakAfter()
|
||||
break
|
||||
}
|
||||
@@ -425,7 +425,7 @@ public class CommentSaver(originalElements: PsiChildRange, private val saveLineB
|
||||
}
|
||||
|
||||
var psiElement = anchor.element
|
||||
for (token in tokensBetween.reverse()) {
|
||||
for (token in tokensBetween.asReversed()) {
|
||||
val next = psiElement.next() ?: break
|
||||
if (next.tokenType != token.tokenType) break
|
||||
psiElement = next
|
||||
|
||||
@@ -55,7 +55,7 @@ public object OptionalParametersHelper {
|
||||
|
||||
val arguments = resolvedCall.getCall().getValueArgumentsInParentheses()
|
||||
val argumentsToDrop = ArrayList<ValueArgument>()
|
||||
for (argument in arguments.reverse()) {
|
||||
for (argument in arguments.asReversed()) {
|
||||
if (!canDrop(argument) || !argument.matchesDefault(resolvedCall, parameterToDefaultValue)) {
|
||||
if (!argument.isNamed()) break else continue // for a named argument we can try to drop arguments before it as well
|
||||
}
|
||||
|
||||
@@ -109,7 +109,7 @@ data class DataForConversion private constructor(
|
||||
}.toString()
|
||||
|
||||
fun IntArray.update() {
|
||||
for (range in rangesToDrop.reverse()) {
|
||||
for (range in rangesToDrop.asReversed()) {
|
||||
for (i in indices) {
|
||||
val offset = this[i]
|
||||
if (offset >= range.end) {
|
||||
|
||||
+1
-1
@@ -64,7 +64,7 @@ public class KotlinCodeBlockSelectioner : ExtendWordSelectionHandlerBase() {
|
||||
private fun findBlockContentEnd(block: PsiElement): Int {
|
||||
val element = block.allChildren
|
||||
.toList()
|
||||
.reverse()
|
||||
.asReversed()
|
||||
.asSequence()
|
||||
.dropWhile { it.getNode().getElementType() != JetTokens.RBRACE } // search for '}'
|
||||
.drop(1) // skip it
|
||||
|
||||
+1
-1
@@ -51,7 +51,7 @@ public class ConvertNegatedExpressionWithDemorgansLawIntention : JetSelfTargetin
|
||||
else -> throw IllegalArgumentException()
|
||||
}
|
||||
|
||||
val operands = splitBooleanSequence(baseExpression)!!.reverse()
|
||||
val operands = splitBooleanSequence(baseExpression)!!.asReversed()
|
||||
|
||||
val newExpression = JetPsiFactory(element).buildExpression {
|
||||
for ((i, operand) in operands.withIndex()) {
|
||||
|
||||
+2
-2
@@ -163,7 +163,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
scope: JetScope): List<TypeCandidate> {
|
||||
if (!typeInfo.substitutionsAllowed) return computeTypeCandidates(typeInfo)
|
||||
return typeCandidates.getOrPut(typeInfo) {
|
||||
val types = typeInfo.getPossibleTypes(this).reverse()
|
||||
val types = typeInfo.getPossibleTypes(this).asReversed()
|
||||
|
||||
// We have to use semantic equality here
|
||||
data class EqWrapper(val _type: JetType) {
|
||||
@@ -187,7 +187,7 @@ class CallableBuilder(val config: CallableBuilderConfiguration) {
|
||||
newTypes.add(EqWrapper(currentFileModule.builtIns.anyType))
|
||||
}
|
||||
|
||||
newTypes.map { TypeCandidate(it._type, scope) }.reverse()
|
||||
newTypes.map { TypeCandidate(it._type, scope) }.reversed()
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +79,7 @@ public class JavaToKotlinPullUpHelperFactory : PullUpHelperFactory {
|
||||
val elementFactory = PsiElementFactory.SERVICE.getInstance(project)
|
||||
|
||||
val dummyTargetClass = createJavaClass(targetClass, null, forcePlainClass = true)
|
||||
val outerClasses = targetClass.parents.filterIsInstance<JetClassOrObject>().toList().reverse()
|
||||
val outerClasses = targetClass.parents.filterIsInstance<JetClassOrObject>().toList().asReversed()
|
||||
|
||||
if (outerClasses.isEmpty()) return dummyFile.add(dummyTargetClass) as PsiClass
|
||||
|
||||
|
||||
@@ -380,8 +380,7 @@ public class ImportInsertHelperImpl(private val project: Project) : ImportInsert
|
||||
}
|
||||
else {
|
||||
val insertAfter = imports
|
||||
.reverse()
|
||||
.firstOrNull {
|
||||
.lastOrNull {
|
||||
val directivePath = it.getImportPath()
|
||||
directivePath != null && ImportPathComparator.compare(directivePath, importPath) <= 0
|
||||
}
|
||||
|
||||
@@ -215,7 +215,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
|
||||
before.remove(before.lastIndex)
|
||||
}
|
||||
|
||||
val elements = before.reverse() + atStart
|
||||
val elements = before.reversed() + atStart
|
||||
commentsAndSpacesUsed.addAll(elements)
|
||||
return Prefix(elements, lineBreaks)
|
||||
}
|
||||
@@ -238,7 +238,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
|
||||
}
|
||||
}
|
||||
|
||||
val result = atEnd.reverse() + after
|
||||
val result = atEnd.reversed() + after
|
||||
commentsAndSpacesUsed.addAll(result)
|
||||
return result
|
||||
}
|
||||
@@ -317,7 +317,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
|
||||
}
|
||||
|
||||
private companion object {
|
||||
fun<T> List<T>.plus(other: List<T>): List<T> {
|
||||
operator fun<T> List<T>.plus(other: List<T>): List<T> {
|
||||
when {
|
||||
isEmpty() -> return other
|
||||
|
||||
@@ -332,11 +332,11 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
|
||||
}
|
||||
}
|
||||
|
||||
fun<T> List<T>.reverse(): List<T> {
|
||||
fun<T> List<T>.reversed(): List<T> {
|
||||
return if (size() <= 1)
|
||||
this
|
||||
else
|
||||
(this as Iterable<T>).reverse()
|
||||
this.asReversed()
|
||||
}
|
||||
|
||||
fun PsiElement.isCommentOrSpace() = this is PsiComment || this is PsiWhiteSpace
|
||||
|
||||
@@ -216,7 +216,7 @@ class DefaultStatementConverter : JavaElementVisitor(), StatementConverter {
|
||||
|
||||
var block = converterForBody.convertBlock(tryBlock)
|
||||
var expression: Expression = Expression.Empty
|
||||
for (variable in resourceVariables.reverse()) {
|
||||
for (variable in resourceVariables.asReversed()) {
|
||||
val parameter = LambdaParameter(Identifier(variable.name!!).assignNoPrototype(), null).assignNoPrototype()
|
||||
val parameterList = ParameterList(listOf(parameter)).assignNoPrototype()
|
||||
val lambda = LambdaExpression(parameterList, block)
|
||||
|
||||
Reference in New Issue
Block a user