Debugger, refactoring in tests: add ability to skip some variables in printFrame

This commit is contained in:
Natalia Ukhorskaya
2016-03-25 11:26:19 +03:00
parent a09814961f
commit 59930c32c4
3 changed files with 15 additions and 6 deletions
@@ -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'
@@ -23,3 +23,5 @@ class MyDelegateThrowsException {
}
// PRINT_FRAME
// SKIP: suppressedExceptions
// SKIP: stackTrace
@@ -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<String> = 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