Rewrite DebuggerTests (do not use FrameTree)
This commit is contained in:
committed by
Nikolay Krasko
parent
5c04959871
commit
7582f1f454
@@ -27,7 +27,6 @@ class MyDelegateThrowsException {
|
||||
|
||||
// PRINT_FRAME
|
||||
frame = main():8, DelegatedPropertyInClassKt {delegatedPropertyInClass}
|
||||
static = static = delegatedPropertyInClass.DelegatedPropertyInClassKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = delegatedPropertyInClass.kt, 5)
|
||||
local = a: delegatedPropertyInClass.A = {delegatedPropertyInClass.A@uniqueID} (sp = delegatedPropertyInClass.kt, 6)
|
||||
field = prop$delegate: delegatedPropertyInClass.MyDelegate = {delegatedPropertyInClass.MyDelegate@uniqueID} (sp = delegatedPropertyInClass.kt, 12)
|
||||
|
||||
@@ -23,7 +23,6 @@ class MyDelegate {
|
||||
// RENDER_DELEGATED_PROPERTIES: false
|
||||
// PRINT_FRAME
|
||||
frame = main():8, DelegatedPropertyInClassWoRendererKt {delegatedPropertyInClassWoRenderer}
|
||||
static = static = delegatedPropertyInClassWoRenderer.DelegatedPropertyInClassWoRendererKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = delegatedPropertyInClassWoRenderer.kt, 5)
|
||||
local = a: delegatedPropertyInClassWoRenderer.A = {delegatedPropertyInClassWoRenderer.A@uniqueID} (sp = delegatedPropertyInClassWoRenderer.kt, 6)
|
||||
field = prop: int = {delegatedPropertyInClassWoRenderer.MyDelegate@uniqueID} (sp = delegatedPropertyInClassWoRenderer.kt, 12)
|
||||
|
||||
@@ -20,8 +20,8 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a2.prop
|
||||
frame = main():14, EvBreakpointOnPropertyDeclarationKt {evBreakpointOnPropertyDeclaration}
|
||||
static = static = evBreakpointOnPropertyDeclaration.EvBreakpointOnPropertyDeclarationKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evBreakpointOnPropertyDeclaration.kt, 7)
|
||||
local = a1: evBreakpointOnPropertyDeclaration.A = {evBreakpointOnPropertyDeclaration.A@uniqueID} (sp = evBreakpointOnPropertyDeclaration.kt, 8)
|
||||
field = prop: int = 1 (sp = evBreakpointOnPropertyDeclaration.kt, 4)
|
||||
|
||||
@@ -19,7 +19,6 @@ fun main(args: Array<String>) {
|
||||
|
||||
// PRINT_FRAME
|
||||
frame = main():13, EvDelegatedPropertyKt {evDelegatedProperty}
|
||||
static = static = evDelegatedProperty.EvDelegatedPropertyKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evDelegatedProperty.kt, 9)
|
||||
local = a: evDelegatedProperty.A = {evDelegatedProperty.A@uniqueID} (sp = evDelegatedProperty.kt, 10)
|
||||
field = prop$delegate: kotlin.properties.ReadWriteProperty = {kotlin.properties.NotNullVar@uniqueID} (sp = evDelegatedProperty.kt, 6)
|
||||
|
||||
@@ -15,8 +15,8 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a.prop
|
||||
frame = main():10, EvDuplicateItemsKt {evDuplicateItems}
|
||||
static = static = evDuplicateItems.EvDuplicateItemsKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evDuplicateItems.kt, 7)
|
||||
local = a: evDuplicateItems.A = {evDuplicateItems.A@uniqueID} (sp = evDuplicateItems.kt, 8)
|
||||
field = prop: int = 1 (sp = evDuplicateItems.kt, 4)
|
||||
|
||||
@@ -16,7 +16,6 @@ fun main(args: Array<String>) {
|
||||
|
||||
// PRINT_FRAME
|
||||
frame = main():10, EvFinalPropertyKt {evFinalProperty}
|
||||
static = static = evFinalProperty.EvFinalPropertyKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evFinalProperty.kt, 7)
|
||||
local = a: evFinalProperty.A = {evFinalProperty.A@uniqueID} (sp = evFinalProperty.kt, 8)
|
||||
field = prop: int = 1 (sp = evFinalProperty.kt, 4)
|
||||
|
||||
+1
-1
@@ -24,8 +24,8 @@ fun main(args: Array<String>) {
|
||||
fun foo(i: Int) {}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a2.prop
|
||||
frame = main():15, EvLineRangeKt {evLineRange}
|
||||
static = static = evLineRange.EvLineRangeKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evLineRange.kt, 7)
|
||||
local = a1: evLineRange.A = {evLineRange.A@uniqueID} (sp = evLineRange.kt, 8)
|
||||
field = prop: int = 1 (sp = evLineRange.kt, 4)
|
||||
|
||||
+1
-1
@@ -17,8 +17,8 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a.prop
|
||||
frame = main():10, EvPropertyKt {evProperty}
|
||||
static = static = evProperty.EvPropertyKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evProperty.kt, 7)
|
||||
local = a: evProperty.A = {evProperty.A@uniqueID} (sp = evProperty.kt, 8)
|
||||
field = prop: int = 1 (sp = evProperty.kt, 4)
|
||||
|
||||
@@ -20,6 +20,7 @@ fun main(args: Array<String>) {
|
||||
}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for prop
|
||||
frame = test():8, A {evPropertyRefExpr}
|
||||
this = this = {evPropertyRefExpr.A@uniqueID}
|
||||
field = prop: int = 1 (sp = evPropertyRefExpr.kt, 4)
|
||||
|
||||
@@ -28,8 +28,8 @@ interface T {
|
||||
fun foo(i: Int) {}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a1.prop
|
||||
frame = main():12, EvSkipAnonymousObjectKt {evSkipAnonymousObject}
|
||||
static = static = evSkipAnonymousObject.EvSkipAnonymousObjectKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evSkipAnonymousObject.kt, 7)
|
||||
local = a1: evSkipAnonymousObject.A = {evSkipAnonymousObject.A@uniqueID} (sp = evSkipAnonymousObject.kt, 8)
|
||||
field = prop: int = 1 (sp = evSkipAnonymousObject.kt, 4)
|
||||
|
||||
+1
-1
@@ -23,8 +23,8 @@ fun foo(i: Int) {}
|
||||
fun l(f: () -> Unit) {}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a1.prop
|
||||
frame = main():12, EvSkipLambdaKt {evSkipLambda}
|
||||
static = static = evSkipLambda.EvSkipLambdaKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evSkipLambda.kt, 7)
|
||||
local = a1: evSkipLambda.A = {evSkipLambda.A@uniqueID} (sp = evSkipLambda.kt, 8)
|
||||
field = prop: int = 1 (sp = evSkipLambda.kt, 4)
|
||||
|
||||
@@ -24,8 +24,8 @@ fun main(args: Array<String>) {
|
||||
fun foo(i: Int) {}
|
||||
|
||||
// PRINT_FRAME
|
||||
Compile bytecode for a1.prop
|
||||
frame = main():12, EvSkipLocalClassKt {evSkipLocalClass}
|
||||
static = static = evSkipLocalClass.EvSkipLocalClassKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = evSkipLocalClass.kt, 7)
|
||||
local = a1: evSkipLocalClass.A = {evSkipLocalClass.A@uniqueID} (sp = evSkipLocalClass.kt, 8)
|
||||
field = prop: int = 1 (sp = evSkipLocalClass.kt, 4)
|
||||
|
||||
@@ -15,7 +15,6 @@ fun main(args: Array<String>) {
|
||||
// RESULT: 1: I
|
||||
|
||||
frame = main():6, FrameClosingBracketKt {frameClosingBracket}
|
||||
static = static = frameClosingBracket.FrameClosingBracketKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = frameClosingBracket.kt, 3)
|
||||
local = a: int = 1 (sp = frameClosingBracket.kt, 4)
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
@@ -28,7 +28,6 @@ fun A.foo() {
|
||||
// EXPRESSION: myFun()
|
||||
// RESULT: 1: I
|
||||
frame = foo():14, FrameExtensionFunKt {frameExtensionFun}
|
||||
static = static = frameExtensionFun.FrameExtensionFunKt
|
||||
local = $receiver: frameExtensionFun.A = {frameExtensionFun.A@uniqueID} (sp = null)
|
||||
field = prop: int = 1 (sp = frameExtensionFun.kt, 8)
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
@@ -12,7 +12,6 @@ fun main(args: Array<String>) {
|
||||
|
||||
// PRINT_FRAME
|
||||
frame = main():6, FrameLocalVariableKt {frameLocalVariable}
|
||||
static = static = frameLocalVariable.FrameLocalVariableKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = frameLocalVariable.kt, 3)
|
||||
local = val1: int = 1 (sp = frameLocalVariable.kt, 4)
|
||||
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||
|
||||
@@ -22,7 +22,6 @@ inline fun foo(f: () -> Unit) {
|
||||
// EXPRESSION: var1
|
||||
// RESULT: 1: I
|
||||
frame = main():7, FrameSharedVarLocalVarKt {frameSharedVarLocalVar}
|
||||
static = static = frameSharedVarLocalVar.FrameSharedVarLocalVarKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = frameSharedVarLocalVar.kt, 3)
|
||||
local = var1: kotlin.jvm.internal.Ref$IntRef = {kotlin.jvm.internal.Ref$IntRef@uniqueID}1 (sp = frameSharedVarLocalVar.kt, 4)
|
||||
field = element: int = 1 (sp = Ref.!EXT!)
|
||||
|
||||
@@ -16,7 +16,6 @@ class A {
|
||||
|
||||
// PRINT_FRAME
|
||||
frame = main():6, ToStringRendererKt {toStringRenderer}
|
||||
static = static = toStringRenderer.ToStringRendererKt
|
||||
local = args: java.lang.String[] = {java.lang.String[0]@uniqueID} (sp = toStringRenderer.kt, 3)
|
||||
local = a: toStringRenderer.A = {toStringRenderer.A@uniqueID}myA (sp = toStringRenderer.kt, 4)
|
||||
- No fields to display
|
||||
|
||||
@@ -34,6 +34,7 @@ import com.intellij.psi.JavaPsiFacade;
|
||||
import com.intellij.psi.PsiClass;
|
||||
import com.intellij.psi.search.GlobalSearchScope;
|
||||
import com.intellij.testFramework.IdeaTestUtil;
|
||||
import com.intellij.xdebugger.XDebugSession;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.kotlin.asJava.FakeLightClassForFileOfPackage;
|
||||
import org.jetbrains.kotlin.asJava.KotlinLightClassForFacade;
|
||||
@@ -238,4 +239,12 @@ public abstract class KotlinDebuggerTestCase extends DescriptorTestCase {
|
||||
e.getActual());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getData(String dataId) {
|
||||
if (XDebugSession.DATA_KEY.is(dataId)) {
|
||||
return myDebuggerSession == null ? null : myDebuggerSession.getXDebugSession();
|
||||
}
|
||||
return super.getData(dataId);
|
||||
}
|
||||
}
|
||||
|
||||
+74
-34
@@ -17,16 +17,14 @@
|
||||
package org.jetbrains.kotlin.idea.debugger.evaluate
|
||||
|
||||
import com.intellij.debugger.SourcePosition
|
||||
import com.intellij.debugger.engine.ContextUtil
|
||||
import com.intellij.debugger.engine.SourcePositionProvider
|
||||
import com.intellij.debugger.engine.SuspendContextImpl
|
||||
import com.intellij.debugger.engine.*
|
||||
import com.intellij.debugger.engine.evaluation.CodeFragmentKind
|
||||
import com.intellij.debugger.engine.evaluation.EvaluateException
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImports
|
||||
import com.intellij.debugger.engine.evaluation.TextWithImportsImpl
|
||||
import com.intellij.debugger.engine.evaluation.expression.EvaluatorBuilderImpl
|
||||
import com.intellij.debugger.impl.DescriptorTestCase
|
||||
import com.intellij.debugger.settings.NodeRendererSettings
|
||||
import com.intellij.debugger.ui.impl.FrameVariablesTree
|
||||
import com.intellij.debugger.ui.impl.watch.*
|
||||
import com.intellij.debugger.ui.tree.FieldDescriptor
|
||||
import com.intellij.debugger.ui.tree.LocalVariableDescriptor
|
||||
@@ -36,8 +34,15 @@ import com.intellij.execution.process.ProcessOutputTypes
|
||||
import com.intellij.openapi.util.Disposer
|
||||
import com.intellij.openapi.util.io.FileUtil
|
||||
import com.intellij.psi.PsiElement
|
||||
import com.intellij.xdebugger.impl.XDebugSessionImpl
|
||||
import com.intellij.xdebugger.impl.breakpoints.XExpressionImpl
|
||||
import com.intellij.xdebugger.impl.frame.XDebugViewSessionListener
|
||||
import com.intellij.xdebugger.impl.frame.XVariablesView
|
||||
import com.intellij.xdebugger.impl.frame.XWatchesViewImpl
|
||||
import com.intellij.xdebugger.impl.ui.XDebuggerUIConstants
|
||||
import com.intellij.xdebugger.impl.ui.tree.ValueMarkup
|
||||
import com.intellij.xdebugger.impl.ui.tree.XDebuggerTree
|
||||
import com.intellij.xdebugger.impl.ui.tree.nodes.*
|
||||
import com.sun.jdi.ObjectReference
|
||||
import org.apache.log4j.AppenderSkeleton
|
||||
import org.apache.log4j.Level
|
||||
@@ -53,8 +58,8 @@ import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils
|
||||
import org.junit.Assert
|
||||
import java.io.File
|
||||
import java.util.Collections
|
||||
import kotlin.test.fail
|
||||
import java.util.*
|
||||
import javax.swing.tree.TreeNode
|
||||
|
||||
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
|
||||
private val logger = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
|
||||
@@ -115,6 +120,9 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
||||
|
||||
doStepping(path)
|
||||
|
||||
val variablesView = createVariablesView()
|
||||
val watchesView = createWatchesView()
|
||||
|
||||
doOnBreakpoint {
|
||||
val exceptions = linkedMapOf<String, Throwable>()
|
||||
try {
|
||||
@@ -131,8 +139,8 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
||||
}
|
||||
}
|
||||
finally {
|
||||
if (shouldPrintFrame) {
|
||||
printFrame()
|
||||
if (shouldPrintFrame) {
|
||||
printFrame(variablesView, watchesView)
|
||||
println(fileText, ProcessOutputTypes.SYSTEM)
|
||||
}
|
||||
else {
|
||||
@@ -174,25 +182,44 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
||||
finish()
|
||||
}
|
||||
|
||||
private fun SuspendContextImpl.printFrame() {
|
||||
val tree = FrameVariablesTree(getProject()!!)
|
||||
Disposer.register(getTestRootDisposable()!!, tree);
|
||||
private fun createWatchesView(): XWatchesViewImpl {
|
||||
val session = myDebuggerSession.xDebugSession as XDebugSessionImpl
|
||||
val watchesView = XWatchesViewImpl(session)
|
||||
Disposer.register(testRootDisposable, watchesView)
|
||||
session.addSessionListener(XDebugViewSessionListener(watchesView), testRootDisposable)
|
||||
return watchesView
|
||||
}
|
||||
|
||||
invokeRatherLater(this) {
|
||||
tree.rebuild(debuggerContext)
|
||||
expandAll(tree, Runnable {
|
||||
try {
|
||||
val printer = Printer()
|
||||
printer.printTree(tree)
|
||||
for (extra in getExtraVars()) {
|
||||
printer.printDescriptor(tree.getNodeFactory().getWatchItemDescriptor(null, extra, null), 2)
|
||||
private fun createVariablesView(): XVariablesView {
|
||||
val session = myDebuggerSession.xDebugSession as XDebugSessionImpl
|
||||
val variablesView = XVariablesView(session)
|
||||
Disposer.register(testRootDisposable, variablesView)
|
||||
session.addSessionListener(XDebugViewSessionListener(variablesView), testRootDisposable)
|
||||
return variablesView
|
||||
}
|
||||
|
||||
private fun SuspendContextImpl.printFrame(variablesView: XVariablesView, watchesView: XWatchesViewImpl) {
|
||||
val tree = variablesView.tree!!
|
||||
expandAll(
|
||||
tree,
|
||||
Runnable {
|
||||
try {
|
||||
Printer().printTree(tree)
|
||||
|
||||
for (extra in getExtraVars()) {
|
||||
watchesView.addWatchExpression(XExpressionImpl.fromText(extra.text), -1, false);
|
||||
}
|
||||
Printer().printTree(watchesView.tree)
|
||||
}
|
||||
}
|
||||
finally {
|
||||
resume(this@printFrame)
|
||||
}
|
||||
})
|
||||
}
|
||||
finally {
|
||||
resume(this)
|
||||
}
|
||||
},
|
||||
hashSetOf(),
|
||||
// TODO why this is needed? Otherwise some tests are never ended
|
||||
DescriptorTestCase.NodeFilter { it !is XValueNodeImpl || it.name != "cause" },
|
||||
this
|
||||
)
|
||||
}
|
||||
|
||||
fun getExtraVars(): Set<TextWithImports> {
|
||||
@@ -200,15 +227,24 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
||||
}
|
||||
|
||||
private inner class Printer() {
|
||||
fun printTree(tree: DebuggerTree) {
|
||||
val root = tree.getMutableModel()!!.getRoot() as DebuggerTreeNodeImpl
|
||||
fun printTree(tree: XDebuggerTree) {
|
||||
val root = tree.treeModel.root as TreeNode
|
||||
printNode(root, 0)
|
||||
}
|
||||
|
||||
private fun printNode(node: DebuggerTreeNodeImpl, indent: Int) {
|
||||
val descriptor: NodeDescriptorImpl = node.getDescriptor()!!
|
||||
private fun printNode(node: TreeNode, indent: Int) {
|
||||
val descriptor = when {
|
||||
node is DebuggerTreeNodeImpl -> node.descriptor
|
||||
node is XValueNodeImpl -> (node.valueContainer as? JavaValue)?.descriptor ?: MessageDescriptor(node.text.toString())
|
||||
node is XStackFrameNode -> (node.valueContainer as? JavaStackFrame)?.descriptor
|
||||
node is XValueGroupNodeImpl -> (node.valueContainer as? JavaStaticGroup)?.descriptor
|
||||
node is WatchesRootNode -> null
|
||||
node is WatchMessageNode -> WatchItemDescriptor(project, TextWithImportsImpl(CodeFragmentKind.EXPRESSION, node.expression.expression))
|
||||
node is MessageTreeNode -> MessageDescriptor(node.text.toString())
|
||||
else -> MessageDescriptor(node.toString())
|
||||
}
|
||||
|
||||
if (printDescriptor(descriptor, indent)) return
|
||||
if (descriptor != null && printDescriptor(descriptor, indent)) return
|
||||
|
||||
printChildren(node, indent + 2)
|
||||
}
|
||||
@@ -216,7 +252,11 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
||||
fun printDescriptor(descriptor: NodeDescriptorImpl, indent: Int): Boolean {
|
||||
if (descriptor is DefaultNodeDescriptor) return true
|
||||
|
||||
val label = descriptor.getLabel()!!
|
||||
var label = descriptor.label
|
||||
// TODO: update presentation before calc label
|
||||
if (label == NodeDescriptorImpl.UNKNOWN_VALUE_MESSAGE && descriptor is StaticDescriptor) {
|
||||
label = "static = " + NodeRendererSettings.getInstance().classRenderer.renderTypeName(descriptor.type.name())
|
||||
}
|
||||
if (label.endsWith(XDebuggerUIConstants.COLLECTING_DATA_MESSAGE)) return true
|
||||
|
||||
val curIndent = " ".repeat(indent)
|
||||
@@ -235,10 +275,10 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestB
|
||||
return false
|
||||
}
|
||||
|
||||
private fun printChildren(node: DebuggerTreeNodeImpl, indent: Int) {
|
||||
val e = node.rawChildren()!!
|
||||
private fun printChildren(node: TreeNode, indent: Int) {
|
||||
val e = node.children()
|
||||
while (e.hasMoreElements()) {
|
||||
printNode(e.nextElement() as DebuggerTreeNodeImpl, indent)
|
||||
printNode(e.nextElement() as TreeNode, indent)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user