EA-210823: Fix AIE in breakpoint applicability test

This commit is contained in:
Yan Zhulanow
2019-11-14 22:31:48 +09:00
parent ab06f772fc
commit 16c4b0e458
2 changed files with 14 additions and 6 deletions
@@ -16,6 +16,7 @@ import com.sun.jdi.AbsentInformationException
import com.sun.jdi.ReferenceType
import org.jetbrains.kotlin.codegen.inline.KOTLIN_STRATA_NAME
import org.jetbrains.kotlin.idea.debugger.isDexDebug
import org.jetbrains.kotlin.idea.debugger.safeSourceName
import org.jetbrains.kotlin.psi.KtElement
import org.jetbrains.kotlin.psi.psiUtil.getNonStrictParentOfType
import org.jetbrains.kotlin.util.containingNonLocalDeclaration
@@ -50,14 +51,15 @@ class KotlinLineBreakpoint(
val lineNumber = sourcePosition.line + 1
for (location in allLineLocations) {
try {
val kotlinFileName = location.sourceName(KOTLIN_STRATA_NAME)
val kotlinLineNumber = location.lineNumber(KOTLIN_STRATA_NAME)
val kotlinFileName = location.safeSourceName(KOTLIN_STRATA_NAME)
val kotlinLineNumber = location.lineNumber(KOTLIN_STRATA_NAME)
if (kotlinFileName != null) {
if (kotlinFileName == fileName && kotlinLineNumber == lineNumber) {
return true
}
} catch (e: AbsentInformationException) {
if (location.sourceName() == fileName && location.lineNumber() == lineNumber) {
} else {
if (location.safeSourceName() == fileName && location.lineNumber() == lineNumber) {
return true
}
}
@@ -62,7 +62,11 @@ fun StackFrameProxy.safeLocation(): Location? {
}
fun Location.safeSourceName(): String? {
return DebuggerUtilsEx.getSourceName(this) { null }
return wrapAbsentInformationException { this.sourceName() }
}
fun Location.safeSourceName(stratum: String): String? {
return wrapAbsentInformationException { this.sourceName(stratum) }
}
fun Location.safeLineNumber(): Int {
@@ -92,6 +96,8 @@ private inline fun <T> wrapAbsentInformationException(block: () -> T): T? {
null
} catch (e: AbsentInformationEvaluateException) {
null
} catch (e: InternalException) {
null
}
}