From 59930c32c48e031cfe188352f27b3862cc448082 Mon Sep 17 00:00:00 2001 From: Natalia Ukhorskaya Date: Fri, 25 Mar 2016 11:26:19 +0300 Subject: [PATCH] Debugger, refactoring in tests: add ability to skip some variables in printFrame --- .../tinyApp/outs/delegatedPropertyInClass.out | 3 ++- .../frame/delegatedPropertyInClass.kt | 2 ++ .../AbstractKotlinEvaluateExpressionTest.kt | 16 +++++++++++----- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out b/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out index 0aec4232a55..c2c53bdc9b6 100644 --- a/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out +++ b/idea/testData/debugger/tinyApp/outs/delegatedPropertyInClass.out @@ -27,6 +27,8 @@ class MyDelegateThrowsException { } // PRINT_FRAME +// SKIP: suppressedExceptions +// SKIP: stackTrace Compile bytecode for args.size frame = main():9, DelegatedPropertyInClassKt {delegatedPropertyInClass} @@ -40,7 +42,6 @@ Compile bytecode for args.size field = propEx: int = {java.lang.IllegalStateException@uniqueID}java.lang.IllegalStateException (sp = delegatedPropertyInClass.kt, 14) field = detailMessage: java.lang.String = null (sp = Throwable.!EXT!) field = cause: java.lang.Throwable = {java.lang.IllegalStateException@uniqueID}java.lang.IllegalStateException (sp = Throwable.!EXT!) - field = stackTrace: java.lang.StackTraceElement[] = null (sp = Throwable.!EXT!) extra = args.size Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket' diff --git a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt index 15b8b485295..6e175e202f1 100644 --- a/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt +++ b/idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/frame/delegatedPropertyInClass.kt @@ -23,3 +23,5 @@ class MyDelegateThrowsException { } // PRINT_FRAME +// SKIP: suppressedExceptions +// SKIP: stackTrace diff --git a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt index e380f73612d..3bdd13d6b70 100644 --- a/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt +++ b/idea/tests/org/jetbrains/kotlin/idea/debugger/evaluate/AbstractKotlinEvaluateExpressionTest.kt @@ -110,6 +110,7 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { createAdditionalBreakpoints(fileText) val shouldPrintFrame = InTextDirectivesUtils.isDirectiveDefined(fileText, "// PRINT_FRAME") + val skipInPrintFrame = if (shouldPrintFrame) InTextDirectivesUtils.findLinesWithPrefixesRemoved(fileText, "// SKIP: ") else emptyList() val expressions = loadTestDirectivesPairs(fileText, "// EXPRESSION: ", "// RESULT: ") @@ -140,7 +141,7 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { } finally { if (shouldPrintFrame) { - printFrame(variablesView, watchesView) + printFrame(variablesView, watchesView, PrinterConfig(skipInPrintFrame)) println(fileText, ProcessOutputTypes.SYSTEM) } else { @@ -198,18 +199,18 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { return variablesView } - private fun SuspendContextImpl.printFrame(variablesView: XVariablesView, watchesView: XWatchesViewImpl) { + private fun SuspendContextImpl.printFrame(variablesView: XVariablesView, watchesView: XWatchesViewImpl, config: PrinterConfig) { val tree = variablesView.tree!! expandAll( tree, Runnable { try { - Printer().printTree(tree) + Printer(config).printTree(tree) for (extra in getExtraVars()) { watchesView.addWatchExpression(XExpressionImpl.fromText(extra.text), -1, false); } - Printer().printTree(watchesView.tree) + Printer(config).printTree(watchesView.tree) } finally { resume(this) @@ -226,7 +227,11 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { return KotlinFrameExtraVariablesProvider().collectVariables(debuggerContext.sourcePosition, evaluationContext, hashSetOf()) } - private inner class Printer() { + private class PrinterConfig( + val variablesToSkipInPrintFrame: List = emptyList() + ) + + private inner class Printer(private val config: PrinterConfig) { fun printTree(tree: XDebuggerTree) { val root = tree.treeModel.root as TreeNode printNode(root, 0) @@ -251,6 +256,7 @@ abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() { fun printDescriptor(descriptor: NodeDescriptorImpl, indent: Int): Boolean { if (descriptor is DefaultNodeDescriptor) return true + if (config.variablesToSkipInPrintFrame.contains(descriptor.name)) return true var label = descriptor.label // TODO: update presentation before calc label