Fix "Should be replaced with Kotlin function" warnings

This commit is contained in:
Dmitry Gridin
2019-04-16 12:12:06 +07:00
parent d738a12b86
commit 3bed360c98
77 changed files with 161 additions and 99 deletions
@@ -27,6 +27,7 @@ import org.jetbrains.kotlin.j2k.ast.SpacesInheritance
import org.jetbrains.kotlin.name.FqName
import org.jetbrains.kotlin.psi.psiUtil.isAncestor
import java.util.*
import kotlin.math.max
fun <T> CodeBuilder.buildList(generators: Collection<() -> T>, separator: String, prefix: String = "", suffix: String = ""): CodeBuilder {
if (generators.isNotEmpty()) {
@@ -192,7 +193,7 @@ class CodeBuilder(private val topElement: PsiElement?, private var docConverter:
return when {
isEmpty() -> other
other.isEmpty() -> this
else -> Prefix(elements + other.elements, Math.max(lineBreaksBefore, other.lineBreaksBefore))
else -> Prefix(elements + other.elements, max(lineBreaksBefore, other.lineBreaksBefore))
}
}
@@ -22,6 +22,7 @@ import com.intellij.util.IncorrectOperationException
import org.jetbrains.kotlin.j2k.ast.*
import org.jetbrains.kotlin.psi.psiUtil.parents
import org.jetbrains.kotlin.psi.psiUtil.siblings
import kotlin.math.abs
class ForConverter(
private val statement: PsiForStatement,
@@ -278,7 +279,7 @@ class ForConverter(
val converted = codeConverter.convertExpression(bound)
val sign = if (correction > 0) JavaTokenType.PLUS else JavaTokenType.MINUS
return BinaryExpression(converted, LiteralExpression(Math.abs(correction).toString()).assignNoPrototype(), Operator(sign).assignPrototype(bound)).assignNoPrototype()
return BinaryExpression(converted, LiteralExpression(abs(correction).toString()).assignNoPrototype(), Operator(sign).assignPrototype(bound)).assignNoPrototype()
}
private fun PsiStatement.toContinuedLoop(): PsiLoopStatement? {