From 5aa6661e3437c9d3fc81464e5a0575c5e96ca72f Mon Sep 17 00:00:00 2001 From: Brandon Fergerson Date: Tue, 26 Sep 2023 11:01:23 -0500 Subject: [PATCH] style: detekt --- .../jvm/presentation/JVMVariableNode.kt | 78 ++++++++++--------- 1 file changed, 43 insertions(+), 35 deletions(-) diff --git a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/presentation/JVMVariableNode.kt b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/presentation/JVMVariableNode.kt index b1891aae0..ecbc8aab8 100644 --- a/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/presentation/JVMVariableNode.kt +++ b/marker/jvm-marker/src/main/kotlin/spp/jetbrains/marker/jvm/presentation/JVMVariableNode.kt @@ -83,42 +83,9 @@ class JVMVariableNode( if (variable.value == null && variable.liveIdentity == null) { presentation.addText("null", REGULAR_ATTRIBUTES) } else if (variable.liveClazz != null && primitives.contains(variable.liveClazz)) { - if (variable.liveClazz == "java.lang.Boolean") { - presentation.addText(variable.value.toString(), REGULAR_ATTRIBUTES) - } else if (variable.liveClazz == "java.lang.Character") { - presentation.addText( - "'" + variable.value + "' " + (variable.value as String).toCharArray()[0].toInt(), - REGULAR_ATTRIBUTES - ) - } else if (variable.liveClazz == "java.lang.String") { - presentation.addText("\"" + variable.value + "\"", fromTextAttributes(scheme.getAttributes(STRING))) - } else if (numerals.contains(variable.liveClazz)) { - presentation.addText(variable.value.toString(), fromTextAttributes(scheme.getAttributes(NUMBER))) - } - presentation.setIcon(AllIcons.Debugger.Db_primitive) + presentPrimitive(variable, presentation) } else if (variable.liveClazz != null) { - val simpleClassName = variable.liveClazz!!.substringAfterLast(".") - var identity = variable.liveIdentity ?: "" - if (identity.isNotEmpty()) { - identity = "@$identity" - } - if (variable.presentation != null) { - presentation.addText("{ $simpleClassName$identity } ", GRAYED_ATTRIBUTES) - presentation.addText("\"${variable.presentation}\"", REGULAR_ATTRIBUTES) - } else { - presentation.addText("{ $simpleClassName$identity }", GRAYED_ATTRIBUTES) - } - presentation.setIcon(AllIcons.Debugger.Value) - - val varValue = variable.value - if (varValue is JsonObject && varValue.getString("@skip") != null) { - val skipReason = varValue.getString("@skip") - if (skipReason == "EXCEPTION_OCCURRED" && varValue.getString("@toString") != null) { - presentation.addText(" " + varValue.getString("@toString"), ERROR_ATTRIBUTES) - } else { - presentation.addText(" $skipReason", ERROR_ATTRIBUTES) - } - } + presentLiveClazz(variable, presentation) } else { if (variable.value is LiveVariable) { val liveVar = variable.value as LiveVariable @@ -151,4 +118,45 @@ class JVMVariableNode( } } } + + private fun presentLiveClazz(variable: LiveVariable, presentation: PresentationData) { + val simpleClassName = variable.liveClazz!!.substringAfterLast(".") + var identity = variable.liveIdentity ?: "" + if (identity.isNotEmpty()) { + identity = "@$identity" + } + if (variable.presentation != null) { + presentation.addText("{ $simpleClassName$identity } ", GRAYED_ATTRIBUTES) + presentation.addText("\"${variable.presentation}\"", REGULAR_ATTRIBUTES) + } else { + presentation.addText("{ $simpleClassName$identity }", GRAYED_ATTRIBUTES) + } + presentation.setIcon(AllIcons.Debugger.Value) + + val varValue = variable.value + if (varValue is JsonObject && varValue.getString("@skip") != null) { + val skipReason = varValue.getString("@skip") + if (skipReason == "EXCEPTION_OCCURRED" && varValue.getString("@toString") != null) { + presentation.addText(" " + varValue.getString("@toString"), ERROR_ATTRIBUTES) + } else { + presentation.addText(" $skipReason", ERROR_ATTRIBUTES) + } + } + } + + private fun presentPrimitive(variable: LiveVariable, presentation: PresentationData) { + if (variable.liveClazz == "java.lang.Boolean") { + presentation.addText(variable.value.toString(), REGULAR_ATTRIBUTES) + } else if (variable.liveClazz == "java.lang.Character") { + presentation.addText( + "'" + variable.value + "' " + (variable.value as String).toCharArray()[0].toInt(), + REGULAR_ATTRIBUTES + ) + } else if (variable.liveClazz == "java.lang.String") { + presentation.addText("\"" + variable.value + "\"", fromTextAttributes(scheme.getAttributes(STRING))) + } else if (numerals.contains(variable.liveClazz)) { + presentation.addText(variable.value.toString(), fromTextAttributes(scheme.getAttributes(NUMBER))) + } + presentation.setIcon(AllIcons.Debugger.Db_primitive) + } }