Debugger: Add stepping tests for function breakpoints
This commit is contained in:
@@ -181,4 +181,9 @@ public class KtPropertyAccessor extends KtDeclarationStub<KotlinPropertyAccessor
|
|||||||
public KtProperty getProperty() {
|
public KtProperty getProperty() {
|
||||||
return (KtProperty) getParent();
|
return (KtProperty) getParent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getTextOffset() {
|
||||||
|
return getNamePlaceholder().getTextRange().getStartOffset();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+16
-1
@@ -53,9 +53,11 @@ import org.jetbrains.annotations.NotNull;
|
|||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
|
import org.jetbrains.java.debugger.breakpoints.properties.JavaMethodBreakpointProperties;
|
||||||
import org.jetbrains.kotlin.asJava.LightClassUtilsKt;
|
import org.jetbrains.kotlin.asJava.LightClassUtilsKt;
|
||||||
|
import org.jetbrains.kotlin.asJava.classes.KtLightClass;
|
||||||
import org.jetbrains.kotlin.psi.KtClass;
|
import org.jetbrains.kotlin.psi.KtClass;
|
||||||
import org.jetbrains.kotlin.psi.KtClassOrObject;
|
import org.jetbrains.kotlin.psi.KtClassOrObject;
|
||||||
import org.jetbrains.kotlin.psi.KtDeclaration;
|
import org.jetbrains.kotlin.psi.KtDeclaration;
|
||||||
|
import org.jetbrains.kotlin.psi.KtPrimaryConstructor;
|
||||||
import org.jetbrains.org.objectweb.asm.Label;
|
import org.jetbrains.org.objectweb.asm.Label;
|
||||||
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
import org.jetbrains.org.objectweb.asm.MethodVisitor;
|
||||||
import org.jetbrains.org.objectweb.asm.Opcodes;
|
import org.jetbrains.org.objectweb.asm.Opcodes;
|
||||||
@@ -570,7 +572,20 @@ public class KotlinFunctionBreakpoint extends BreakpointWithHighlighter<JavaMeth
|
|||||||
KtDeclaration declaration = PositionUtil.getPsiElementAt(project, KtDeclaration.class, sourcePosition);
|
KtDeclaration declaration = PositionUtil.getPsiElementAt(project, KtDeclaration.class, sourcePosition);
|
||||||
|
|
||||||
if (declaration instanceof KtClass) {
|
if (declaration instanceof KtClass) {
|
||||||
declaration = ((KtClass) declaration).getPrimaryConstructor();
|
KtPrimaryConstructor constructor = ((KtClass) declaration).getPrimaryConstructor();
|
||||||
|
if (constructor != null) {
|
||||||
|
declaration = constructor;
|
||||||
|
} else {
|
||||||
|
KtLightClass lightClass = LightClassUtilsKt.toLightClass((KtClassOrObject) declaration);
|
||||||
|
if (lightClass != null) {
|
||||||
|
PsiMethod[] constructors = lightClass.getConstructors();
|
||||||
|
if (constructors.length > 0) {
|
||||||
|
return constructors[0];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (declaration == null) {
|
if (declaration == null) {
|
||||||
|
|||||||
+2
-2
@@ -171,10 +171,10 @@ class LineBreakpointExpressionVisitor private constructor(
|
|||||||
return Lines.EMPTY
|
return Lines.EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
val startOffset = this.startOffset
|
val startOffset = maxOf(this.startOffset, this.textOffset)
|
||||||
val endOffset = this.endOffset
|
val endOffset = this.endOffset
|
||||||
|
|
||||||
if (startOffset < 0 || endOffset < 0) {
|
if (startOffset < 0 || endOffset < 0 || startOffset > endOffset) {
|
||||||
return Lines.EMPTY
|
return Lines.EMPTY
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,105 @@
|
|||||||
|
package functionBreakpoints
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class A
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class B()
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class C {}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class D(val a: Int)
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class E(
|
||||||
|
val a: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
class F(
|
||||||
|
//Breakpoint!
|
||||||
|
val a: Int
|
||||||
|
)
|
||||||
|
|
||||||
|
class G {
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
constructor(a: Int) {}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
constructor(a: String) {}
|
||||||
|
}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class H(val a: String) {
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
constructor(a: Int) : this("f")
|
||||||
|
}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
class K {
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun a() {}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun b() {
|
||||||
|
}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun c(a: Int) {
|
||||||
|
b()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun topLevel1() {}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun topLevel2(
|
||||||
|
a: Int
|
||||||
|
) {}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun topLevel3(a: Int = foo()) {}
|
||||||
|
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
fun foo() = 3
|
||||||
|
|
||||||
|
class L {
|
||||||
|
val a: Int
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
get() = 1
|
||||||
|
|
||||||
|
var b: Int
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
get() = 1
|
||||||
|
//FunctionBreakpoint!
|
||||||
|
set(v) { topLevel2(v) }
|
||||||
|
}
|
||||||
|
|
||||||
|
fun main() {
|
||||||
|
A()
|
||||||
|
B()
|
||||||
|
C()
|
||||||
|
D(0)
|
||||||
|
E(0)
|
||||||
|
F(0)
|
||||||
|
G(0)
|
||||||
|
G("")
|
||||||
|
H(0)
|
||||||
|
H("")
|
||||||
|
|
||||||
|
val k = K()
|
||||||
|
k.a()
|
||||||
|
k.b()
|
||||||
|
k.c(0)
|
||||||
|
|
||||||
|
topLevel1()
|
||||||
|
topLevel2(0)
|
||||||
|
topLevel3()
|
||||||
|
|
||||||
|
val l = L()
|
||||||
|
l.a
|
||||||
|
l.b
|
||||||
|
l.b = 2
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:4
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:7
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:10
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:13
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:16
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:27
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:30
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:34
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:36
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:40
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:42
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:45
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:49
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:55
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:58
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:63
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:66
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:71
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:75
|
||||||
|
FunctionBreakpoint created at functionBreakpoints.kt:77
|
||||||
|
Run Java
|
||||||
|
Connected to the target VM
|
||||||
|
functionBreakpoints.kt:4
|
||||||
|
resuming functionBreakpoints.kt:7
|
||||||
|
resuming functionBreakpoints.kt:10
|
||||||
|
resuming functionBreakpoints.kt:13
|
||||||
|
resuming functionBreakpoints.kt:16
|
||||||
|
resuming functionBreakpoints.kt:27
|
||||||
|
resuming functionBreakpoints.kt:30
|
||||||
|
resuming functionBreakpoints.kt:36
|
||||||
|
resuming functionBreakpoints.kt:34
|
||||||
|
resuming functionBreakpoints.kt:34
|
||||||
|
resuming functionBreakpoints.kt:40
|
||||||
|
resuming functionBreakpoints.kt:42
|
||||||
|
resuming functionBreakpoints.kt:46
|
||||||
|
resuming functionBreakpoints.kt:50
|
||||||
|
resuming functionBreakpoints.kt:46
|
||||||
|
resuming functionBreakpoints.kt:51
|
||||||
|
resuming functionBreakpoints.kt:55
|
||||||
|
resuming functionBreakpoints.kt:60
|
||||||
|
resuming functionBreakpoints.kt:66
|
||||||
|
resuming functionBreakpoints.kt:63
|
||||||
|
resuming functionBreakpoints.kt:71
|
||||||
|
resuming functionBreakpoints.kt:75
|
||||||
|
resuming functionBreakpoints.kt:77
|
||||||
|
resuming functionBreakpoints.kt:60
|
||||||
|
Disconnected from the target VM
|
||||||
|
|
||||||
|
Process finished with exit code 0
|
||||||
+7
@@ -0,0 +1,7 @@
|
|||||||
|
/*
|
||||||
|
* Copyright 2010-2019 JetBrains s.r.o. and Kotlin Programming Language contributors.
|
||||||
|
* Use of this source code is governed by the Apache 2.0 license that can be found in the license/LICENSE.txt file.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.jetbrains.kotlin.idea.debugger
|
||||||
|
|
||||||
+5
@@ -1067,6 +1067,11 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
|||||||
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/funLiteral.kt");
|
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/funLiteral.kt");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@TestMetadata("functionBreakpoints.kt")
|
||||||
|
public void testFunctionBreakpoints() throws Exception {
|
||||||
|
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/functionBreakpoints.kt");
|
||||||
|
}
|
||||||
|
|
||||||
@TestMetadata("functionCallStoredToVariable.kt")
|
@TestMetadata("functionCallStoredToVariable.kt")
|
||||||
public void testFunctionCallStoredToVariable() throws Exception {
|
public void testFunctionCallStoredToVariable() throws Exception {
|
||||||
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/functionCallStoredToVariable.kt");
|
runTest("idea/testData/debugger/tinyApp/src/stepping/custom/functionCallStoredToVariable.kt");
|
||||||
|
|||||||
Reference in New Issue
Block a user