Add tests on smart step into lambda
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at funLiteral.kt:5
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! funLiteral.FunLiteralPackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
funLiteral.kt:5
|
||||||
|
funLiteral.kt:6
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at severalFunLiterals.kt:6
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! severalFunLiterals.SeveralFunLiteralsPackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
severalFunLiterals.kt:6
|
||||||
|
severalFunLiterals.kt:7
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
LineBreakpoint created at severalFunLiteralsInClass.kt:20
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !APP_PATH!\classes;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! severalFunLiteralsInClass.SeveralFunLiteralsInClassPackage
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
severalFunLiteralsInClass.kt:20
|
||||||
|
severalFunLiteralsInClass.kt:21
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
package funLiteral
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
//Breakpoint!
|
||||||
|
f1() {
|
||||||
|
f2()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f1(f: () -> Unit) { f() }
|
||||||
|
fun f2() {}
|
||||||
|
|
||||||
|
// SMART_STEP_INTO_BY_INDEX: 1
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
package severalFunLiterals
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
val myClass = MyClass()
|
||||||
|
//Breakpoint!
|
||||||
|
myClass.f1 { test() }.f2 {
|
||||||
|
test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
fun f1(f1Param: () -> Unit): MyClass {
|
||||||
|
f1Param()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f2(f2Param: () -> Unit): MyClass {
|
||||||
|
f2Param()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {}
|
||||||
|
|
||||||
|
// SMART_STEP_INTO_BY_INDEX: 3
|
||||||
+28
@@ -0,0 +1,28 @@
|
|||||||
|
package severalFunLiteralsInClass
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
MyClass().inClass()
|
||||||
|
}
|
||||||
|
|
||||||
|
class MyClass {
|
||||||
|
fun f1(f1Param: () -> Unit): MyClass {
|
||||||
|
f1Param()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun f2(f2Param: () -> Unit): MyClass {
|
||||||
|
f2Param()
|
||||||
|
return this
|
||||||
|
}
|
||||||
|
|
||||||
|
fun inClass() {
|
||||||
|
//Breakpoint!
|
||||||
|
f1 { test() }.f2 {
|
||||||
|
test()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fun test() {}
|
||||||
|
|
||||||
|
// SMART_STEP_INTO_BY_INDEX: 3
|
||||||
@@ -20,13 +20,12 @@ import com.intellij.debugger.DebuggerManagerEx
|
|||||||
import com.intellij.debugger.actions.MethodSmartStepTarget
|
import com.intellij.debugger.actions.MethodSmartStepTarget
|
||||||
import com.intellij.debugger.actions.SmartStepTarget
|
import com.intellij.debugger.actions.SmartStepTarget
|
||||||
import com.intellij.debugger.engine.BasicStepMethodFilter
|
import com.intellij.debugger.engine.BasicStepMethodFilter
|
||||||
|
import com.intellij.debugger.engine.MethodFilter
|
||||||
import com.intellij.debugger.engine.NamedMethodFilter
|
import com.intellij.debugger.engine.NamedMethodFilter
|
||||||
import com.intellij.debugger.engine.SuspendContextImpl
|
import com.intellij.debugger.engine.SuspendContextImpl
|
||||||
import com.intellij.debugger.ui.breakpoints.LineBreakpoint
|
import com.intellij.debugger.ui.breakpoints.LineBreakpoint
|
||||||
import com.intellij.openapi.util.io.FileUtil
|
import com.intellij.openapi.util.io.FileUtil
|
||||||
import org.jetbrains.kotlin.idea.debugger.stepping.KotlinBasicStepMethodFilter
|
import org.jetbrains.kotlin.idea.debugger.stepping.*
|
||||||
import org.jetbrains.kotlin.idea.debugger.stepping.KotlinMethodSmartStepTarget
|
|
||||||
import org.jetbrains.kotlin.idea.debugger.stepping.KotlinSmartStepIntoHandler
|
|
||||||
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
import org.jetbrains.kotlin.idea.util.application.runReadAction
|
||||||
import org.jetbrains.kotlin.test.InTextDirectivesUtils.getPrefixedInt
|
import org.jetbrains.kotlin.test.InTextDirectivesUtils.getPrefixedInt
|
||||||
import java.io.File
|
import java.io.File
|
||||||
@@ -58,10 +57,11 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() {
|
|||||||
|
|
||||||
File(path).readLines().forEach {
|
File(path).readLines().forEach {
|
||||||
when {
|
when {
|
||||||
it.startsWith("// STEP_INTO") -> repeat("// STEP_INTO: ") { stepInto(this) }
|
it.startsWith("// STEP_INTO: ") -> repeat("// STEP_INTO: ") { stepInto(this) }
|
||||||
it.startsWith("// STEP_OUT") -> repeat("// STEP_OUT: ") { stepOut() }
|
it.startsWith("// STEP_OUT: ") -> repeat("// STEP_OUT: ") { stepOut() }
|
||||||
it.startsWith("// SMART_STEP_INTO") -> repeat("// SMART_STEP_INTO: ") { smartStepInto() }
|
it.startsWith("// SMART_STEP_INTO_BY_INDEX: ") -> doOnBreakpoint { smartStepInto(getPrefixedInt(it, "// SMART_STEP_INTO_BY_INDEX: ")!!) }
|
||||||
it.startsWith("// RESUME") -> repeat("// RESUME: ") { resume(this) }
|
it.startsWith("// SMART_STEP_INTO: ") -> repeat("// SMART_STEP_INTO: ") { smartStepInto() }
|
||||||
|
it.startsWith("// RESUME: ") -> repeat("// RESUME: ") { resume(this) }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,17 +88,23 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() {
|
|||||||
finish()
|
finish()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SuspendContextImpl.smartStepInto() {
|
private fun SuspendContextImpl.smartStepInto(chooseFromList: Int = 0) {
|
||||||
this.smartStepInto(false)
|
this.smartStepInto(chooseFromList, false)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun SuspendContextImpl.smartStepInto(ignoreFilters: Boolean) {
|
private fun SuspendContextImpl.smartStepInto(chooseFromList: Int, ignoreFilters: Boolean) {
|
||||||
createSmartStepIntoFilters().forEach {
|
val filters = createSmartStepIntoFilters()
|
||||||
dp.getManagerThread()!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, it))
|
if (chooseFromList == 0) {
|
||||||
|
filters.forEach {
|
||||||
|
dp.getManagerThread()!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, it))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
dp.getManagerThread()!!.schedule(dp.createStepIntoCommand(this, ignoreFilters, filters.get(chooseFromList)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun createSmartStepIntoFilters(): List<NamedMethodFilter> {
|
private fun createSmartStepIntoFilters(): List<MethodFilter> {
|
||||||
val breakpointManager = DebuggerManagerEx.getInstanceEx(getProject())?.getBreakpointManager()
|
val breakpointManager = DebuggerManagerEx.getInstanceEx(getProject())?.getBreakpointManager()
|
||||||
val breakpoint = breakpointManager?.getBreakpoints()?.first { it is LineBreakpoint }
|
val breakpoint = breakpointManager?.getBreakpoints()?.first { it is LineBreakpoint }
|
||||||
|
|
||||||
@@ -115,6 +121,7 @@ public abstract class AbstractKotlinSteppingTest : KotlinDebuggerTestBase() {
|
|||||||
stepTargets.filterIsInstance<SmartStepTarget>().map {
|
stepTargets.filterIsInstance<SmartStepTarget>().map {
|
||||||
stepTarget ->
|
stepTarget ->
|
||||||
when (stepTarget) {
|
when (stepTarget) {
|
||||||
|
is KotlinLambdaSmartStepTarget -> KotlinLambdaMethodFilter(stepTarget.getLambda(), stepTarget.getCallingExpressionLines()!!)
|
||||||
is KotlinMethodSmartStepTarget -> KotlinBasicStepMethodFilter(stepTarget.resolvedElement, stepTarget.getCallingExpressionLines()!!)
|
is KotlinMethodSmartStepTarget -> KotlinBasicStepMethodFilter(stepTarget.resolvedElement, stepTarget.getCallingExpressionLines()!!)
|
||||||
is MethodSmartStepTarget -> BasicStepMethodFilter(stepTarget.getMethod(), stepTarget.getCallingExpressionLines())
|
is MethodSmartStepTarget -> BasicStepMethodFilter(stepTarget.getMethod(), stepTarget.getCallingExpressionLines())
|
||||||
else -> null
|
else -> null
|
||||||
|
|||||||
@@ -382,6 +382,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepping/custom"), Pattern.compile("^(.+)\\.kt$"), true);
|
JetTestUtils.assertAllTestsPresentByMetadata(this.getClass(), new File("idea/testData/debugger/tinyApp/src/stepping/custom"), Pattern.compile("^(.+)\\.kt$"), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("funLiteral.kt")
|
||||||
|
public void testFunLiteral() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/funLiteral.kt");
|
||||||
|
doCustomTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("fwAbstractProperty.kt")
|
@TestMetadata("fwAbstractProperty.kt")
|
||||||
public void testFwAbstractProperty() throws Exception {
|
public void testFwAbstractProperty() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/fwAbstractProperty.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/fwAbstractProperty.kt");
|
||||||
@@ -400,6 +406,18 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
doCustomTest(fileName);
|
doCustomTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("severalFunLiterals.kt")
|
||||||
|
public void testSeveralFunLiterals() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/severalFunLiterals.kt");
|
||||||
|
doCustomTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
|
@TestMetadata("severalFunLiteralsInClass.kt")
|
||||||
|
public void testSeveralFunLiteralsInClass() throws Exception {
|
||||||
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/severalFunLiteralsInClass.kt");
|
||||||
|
doCustomTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("stepIntoStdlibInlineFun2step.kt")
|
@TestMetadata("stepIntoStdlibInlineFun2step.kt")
|
||||||
public void testStepIntoStdlibInlineFun2step() throws Exception {
|
public void testStepIntoStdlibInlineFun2step() throws Exception {
|
||||||
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/stepIntoStdlibInlineFun2step.kt");
|
String fileName = JetTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/custom/stepIntoStdlibInlineFun2step.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user