Fix breakpoints from Kotlin file placed in irrelevant class (KT-19429)
State that there're no locations in given file, if all locations for line were filtered out because of wrong file name. Need this because if we throw exception, other positions managers may return locations without explicit check for file type or file name. See PositionManagerImpl.java #KT-19429 Fixed
This commit is contained in:
@@ -261,12 +261,12 @@ class KotlinPositionManager(private val myDebugProcess: DebugProcess) : MultiReq
|
||||
|
||||
val line = position.line + 1
|
||||
|
||||
val locations = type.locationsOfLine(KOTLIN_STRATA_NAME, null, line).filter { it.sourceName(KOTLIN_STRATA_NAME) == position.file.name }
|
||||
if (locations.isEmpty()) {
|
||||
val locations = type.locationsOfLine(KOTLIN_STRATA_NAME, null, line)
|
||||
if (locations == null || locations.isEmpty()) {
|
||||
throw NoDataException.INSTANCE
|
||||
}
|
||||
|
||||
return locations
|
||||
return locations.filter { it.sourceName(KOTLIN_STRATA_NAME) == position.file.name }
|
||||
}
|
||||
catch (e: AbsentInformationException) {
|
||||
throw NoDataException.INSTANCE
|
||||
|
||||
+11
@@ -0,0 +1,11 @@
|
||||
package stopInWrongClass
|
||||
|
||||
class A {
|
||||
fun test() {
|
||||
// Breakpoint 1
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun foo() {
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package stopInWrongClass
|
||||
|
||||
class AA {
|
||||
fun test() {
|
||||
// Should be on the same line with Breakpoint 1
|
||||
foo()
|
||||
}
|
||||
|
||||
fun other() {
|
||||
//Breakpoint!
|
||||
foo()
|
||||
}
|
||||
}
|
||||
|
||||
fun main(args: Array<String>) {
|
||||
// Shouldn't stop inside test()
|
||||
AA().test()
|
||||
AA().other()
|
||||
}
|
||||
|
||||
// ADDITIONAL_BREAKPOINT: stopInWrongClass.Other.kt: Breakpoint 1
|
||||
@@ -0,0 +1,9 @@
|
||||
LineBreakpoint created at stopInWrongClass.Other.kt:6
|
||||
LineBreakpoint created at stopInWrongClass.kt:11
|
||||
Run Java
|
||||
Connected to the target VM
|
||||
stopInWrongClass.kt:11
|
||||
stopInWrongClass.kt:12
|
||||
Disconnected from the target VM
|
||||
|
||||
Process finished with exit code 0
|
||||
@@ -998,6 +998,12 @@ public class KotlinSteppingTestGenerated extends AbstractKotlinSteppingTest {
|
||||
doStepOverTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("stopInWrongClass.kt")
|
||||
public void testStopInWrongClass() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInWrongClass.kt");
|
||||
doStepOverTest(fileName);
|
||||
}
|
||||
|
||||
@TestMetadata("stopInlineCallInLocalFunInSecondaryConstructor.kt")
|
||||
public void testStopInlineCallInLocalFunInSecondaryConstructor() throws Exception {
|
||||
String fileName = KotlinTestUtils.navigationMetadata("idea/testData/debugger/tinyApp/src/stepping/stepOver/stopInlineCallInLocalFunInSecondaryConstructor.kt");
|
||||
|
||||
Reference in New Issue
Block a user