Cleanup: apply "cascade if..." inspection (+ some others)

This commit is contained in:
Mikhail Glukhikh
2017-06-28 15:19:20 +03:00
committed by Mikhail Glukhikh
parent 9c06739594
commit 1d2017b0fc
80 changed files with 1079 additions and 1190 deletions
@@ -190,35 +190,27 @@ object Constants {
private fun formatChar(c: Char) = '\'' + quote(c) + '\''
private fun formatString(s: String) = '"' + quote(s) + '"'
private fun formatFloat(f: Float): String {
if (java.lang.Float.isNaN(f))
return "0.0f/0.0f"
else if (java.lang.Float.isInfinite(f))
return if (f < 0) "-1.0f/0.0f" else "1.0f/0.0f"
else
return "${f}f"
private fun formatFloat(f: Float): String = when {
java.lang.Float.isNaN(f) -> "0.0f/0.0f"
java.lang.Float.isInfinite(f) -> if (f < 0) "-1.0f/0.0f" else "1.0f/0.0f"
else -> "${f}f"
}
private fun formatDouble(d: Double): String {
if (java.lang.Double.isNaN(d))
return "0.0/0.0"
else if (java.lang.Double.isInfinite(d))
return if (d < 0) "-1.0/0.0" else "1.0/0.0"
else
return d.toString()
private fun formatDouble(d: Double): String = when {
java.lang.Double.isNaN(d) -> "0.0/0.0"
java.lang.Double.isInfinite(d) -> if (d < 0) "-1.0/0.0" else "1.0/0.0"
else -> d.toString()
}
fun quote(ch: Char): String {
return when (ch) {
'\b' -> "\\b"
'\n' -> "\\n"
'\r' -> "\\r"
'\t' -> "\\t"
'\'' -> "\\'"
'\"' -> "\\\""
'\\' -> "\\\\"
else -> if (isPrintableAscii(ch)) ch.toString() else String.format("\\u%04x", ch.toInt())
}
fun quote(ch: Char): String = when (ch) {
'\b' -> "\\b"
'\n' -> "\\n"
'\r' -> "\\r"
'\t' -> "\\t"
'\'' -> "\\'"
'\"' -> "\\\""
'\\' -> "\\\\"
else -> if (isPrintableAscii(ch)) ch.toString() else String.format("\\u%04x", ch.toInt())
}
fun quote(s: String): String {
@@ -95,12 +95,10 @@ class KotlinTypes(
if (extendsBound != null && extendsBound !is JePsiType) illegalArg("extendsBound should have PsiType")
if (superBound != null && superBound !is JePsiType) illegalArg("superBound should have PsiType")
return JeWildcardType(if (extendsBound != null) {
PsiWildcardType.createExtends(psiManager(), (extendsBound as JePsiType).psiType)
} else if (superBound != null) {
PsiWildcardType.createSuper(psiManager(), (superBound as JePsiType).psiType)
} else {
PsiWildcardType.createUnbounded(psiManager())
return JeWildcardType(when {
extendsBound != null -> PsiWildcardType.createExtends(psiManager(), (extendsBound as JePsiType).psiType)
superBound != null -> PsiWildcardType.createSuper(psiManager(), (superBound as JePsiType).psiType)
else -> PsiWildcardType.createUnbounded(psiManager())
}, isRaw = false)
}