Debugger: add breakpoint variant for line with lambda in init block
#KT-KT-1061 Fixed
This commit is contained in:
+2
-1
@@ -35,6 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
|
import org.jetbrains.java.debugger.breakpoints.properties.JavaBreakpointProperties;
|
||||||
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
|
import org.jetbrains.java.debugger.breakpoints.properties.JavaLineBreakpointProperties;
|
||||||
import org.jetbrains.kotlin.idea.KotlinIcons;
|
import org.jetbrains.kotlin.idea.KotlinIcons;
|
||||||
|
import org.jetbrains.kotlin.psi.KtClassInitializer;
|
||||||
import org.jetbrains.kotlin.psi.KtFunction;
|
import org.jetbrains.kotlin.psi.KtFunction;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
@@ -96,7 +97,7 @@ public class KotlinLineBreakpointType extends JavaLineBreakpointType {
|
|||||||
@Nullable
|
@Nullable
|
||||||
public static PsiElement getContainingMethod(@Nullable PsiElement elem) {
|
public static PsiElement getContainingMethod(@Nullable PsiElement elem) {
|
||||||
//noinspection unchecked
|
//noinspection unchecked
|
||||||
return PsiTreeUtil.getParentOfType(elem, KtFunction.class);
|
return PsiTreeUtil.getParentOfType(elem, KtFunction.class, KtClassInitializer.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean inTheMethod(@NotNull SourcePosition pos, @NotNull PsiElement method) {
|
public static boolean inTheMethod(@NotNull SourcePosition pos, @NotNull PsiElement method) {
|
||||||
|
|||||||
@@ -108,10 +108,8 @@ fun computeVariants(
|
|||||||
XSourcePositionImpl.createByElement(lambda.bodyExpression), lambda, ordinal))
|
XSourcePositionImpl.createByElement(lambda.bodyExpression), lambda, ordinal))
|
||||||
}
|
}
|
||||||
|
|
||||||
if (result.size > 1) {
|
val allBreakpoint = (kotlinBreakpointType as JavaLineBreakpointType).JavaBreakpointVariant(position)
|
||||||
val allBreakpoint = (kotlinBreakpointType as JavaLineBreakpointType).JavaBreakpointVariant(position)
|
result.addFirst(allBreakpoint)
|
||||||
result.addFirst(allBreakpoint)
|
|
||||||
}
|
|
||||||
|
|
||||||
return result
|
return result
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
LineBreakpoint created at initializer.kt:12
|
||||||
|
LineBreakpoint created at initializer.kt:18 lambdaOrdinal = -1
|
||||||
|
!JDK_HOME!\bin\java -agentlib:jdwp=transport=dt_socket,address=!HOST_NAME!:!HOST_PORT!,suspend=y,server=n -Dfile.encoding=!FILE_ENCODING! -classpath !OUTPUT_PATH!;!KOTLIN_RUNTIME!;!CUSTOM_LIBRARY!;!RT_JAR! initializer.InitializerKt
|
||||||
|
Connected to the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
initializer.kt:12
|
||||||
|
Compile bytecode for prop
|
||||||
|
initializer.kt:18
|
||||||
|
Disconnected from the target VM, address: '!HOST_NAME!:PORT_NAME!', transport: 'socket'
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
|
1
|
||||||
+20
@@ -0,0 +1,20 @@
|
|||||||
|
package initializer
|
||||||
|
|
||||||
|
fun main(args: Array<String>) {
|
||||||
|
A(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
class A(val prop: Int) {
|
||||||
|
init {
|
||||||
|
// EXPRESSION: prop
|
||||||
|
// RESULT: 1: I
|
||||||
|
//Breakpoint!
|
||||||
|
val a = 1
|
||||||
|
|
||||||
|
val list = listOf(1)
|
||||||
|
// EXPRESSION: it
|
||||||
|
// RESULT: Unresolved reference: it
|
||||||
|
//Breakpoint! (lambdaOrdinal = -1)
|
||||||
|
list.forEach { println(it) }
|
||||||
|
}
|
||||||
|
}
|
||||||
+6
@@ -736,6 +736,12 @@ public class KotlinEvaluateExpressionTestGenerated extends AbstractKotlinEvaluat
|
|||||||
doMultipleBreakpointsTest(fileName);
|
doMultipleBreakpointsTest(fileName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("initializer.kt")
|
||||||
|
public void testInitializer() throws Exception {
|
||||||
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/initializer.kt");
|
||||||
|
doMultipleBreakpointsTest(fileName);
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("isInsideInlineLambda.kt")
|
@TestMetadata("isInsideInlineLambda.kt")
|
||||||
public void testIsInsideInlineLambda() throws Exception {
|
public void testIsInsideInlineLambda() throws Exception {
|
||||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/isInsideInlineLambda.kt");
|
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/evaluate/multipleBreakpoints/isInsideInlineLambda.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user