Debugger: get correct context for breakpoints inside lambdas

This commit is contained in:
Natalia Ukhorskaya
2014-09-11 14:15:27 +04:00
parent a1e586cf7c
commit 50dcef254d
19 changed files with 351 additions and 38 deletions
@@ -59,7 +59,7 @@ import com.intellij.debugger.DebuggerManagerEx
import com.intellij.psi.PsiDocumentManager
import com.intellij.openapi.application.ModalityState
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestCase() {
public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestBase() {
private val logger = Logger.getLogger(javaClass<KotlinEvaluateExpressionCache>())!!
private val appender = object : AppenderSkeleton() {
@@ -73,7 +73,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC
private var oldLogLevel: Level? = null
override fun setUp() {
super<KotlinDebuggerTestCase>.setUp()
super.setUp()
oldLogLevel = logger.getLevel()
logger.setLevel(Level.DEBUG)
@@ -84,7 +84,7 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC
logger.setLevel(oldLogLevel)
logger.removeAppender(appender)
super<KotlinDebuggerTestCase>.tearDown()
super.tearDown()
}
fun doSingleBreakpointTest(path: String) {
@@ -102,6 +102,13 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC
createDebugProcess(path)
val count = InTextDirectivesUtils.getPrefixedInt(fileText, "// STEP_INTO: ") ?: 0
if (count > 0) {
for (i in 1..count) {
onBreakpoint { stepInto() }
}
}
onBreakpoint {
val exceptions = linkedMapOf<String, Throwable>()
try {
@@ -275,19 +282,6 @@ public abstract class AbstractKotlinEvaluateExpressionTest : KotlinDebuggerTestC
return mainFile.getParentFile()?.listFiles()?.filter { it.name.startsWith(mainFileName) && it.name != mainFileName } ?: Collections.emptyList()
}
private fun onBreakpoint(doOnBreakpoint: SuspendContextImpl.() -> Unit) {
super.onBreakpoint {
super.printContext(it)
it.doOnBreakpoint()
}
}
private fun finish() {
onBreakpoint {
resume(this)
}
}
private fun SuspendContextImpl.evaluate(text: String, codeFragmentKind: CodeFragmentKind, expectedResult: String) {
ApplicationManager.getApplication()?.runReadAction {
val sourcePosition = ContextUtil.getSourcePosition(this)
@@ -35,7 +35,7 @@ import java.util.regex.Pattern;
public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluateExpressionTest {
@TestMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint")
@TestDataPath("$PROJECT_ROOT")
@InnerTestClasses({SingleBreakpoint.Frame.class})
@InnerTestClasses({SingleBreakpoint.Frame.class, SingleBreakpoint.Lambdas.class})
@RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)
public static class SingleBreakpoint extends AbstractKotlinEvaluateExpressionTest {
@TestMetadata("abstractFunCall.kt")
@@ -54,6 +54,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
doSingleBreakpointTest(fileName);
}
@TestMetadata("callableBug.kt")
public void testCallableBug() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/callableBug.kt");
doSingleBreakpointTest(fileName);
}
@TestMetadata("classFromAnotherPackage.kt")
public void testClassFromAnotherPackage() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/classFromAnotherPackage.kt");
@@ -262,6 +268,46 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
}
@TestMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas")
@TestDataPath("$PROJECT_ROOT")
@RunWith(org.jetbrains.jet.JUnit3RunnerWithInners.class)
public static class Lambdas extends AbstractKotlinEvaluateExpressionTest {
public void testAllFilesPresentInLambdas() throws Exception {
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas"), Pattern.compile("^(.+)\\.kt$"), true);
}
@TestMetadata("inlineLambda.kt")
public void testInlineLambda() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/inlineLambda.kt");
doSingleBreakpointTest(fileName);
}
@TestMetadata("lambdaOnSecondLine.kt")
public void testLambdaOnSecondLine() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/lambdaOnSecondLine.kt");
doSingleBreakpointTest(fileName);
}
@TestMetadata("oneLineLambda.kt")
public void testOneLineLambda() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/oneLineLambda.kt");
doSingleBreakpointTest(fileName);
}
@TestMetadata("twoLambdasOnOneLineFirst.kt")
public void testTwoLambdasOnOneLineFirst() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/twoLambdasOnOneLineFirst.kt");
doSingleBreakpointTest(fileName);
}
@TestMetadata("twoLambdasOnOneLineSecond.kt")
public void testTwoLambdasOnOneLineSecond() throws Exception {
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/singleBreakpoint/lambdas/twoLambdasOnOneLineSecond.kt");
doSingleBreakpointTest(fileName);
}
}
}
@TestMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints")