Debugger: Disable exception on 'variable not found' event (EA-138365)
The error message is still visible to the user, so it doesn't make much sense to duplicate it as an exception.
This commit is contained in:
+1
-4
@@ -409,10 +409,7 @@ class KotlinEvaluator(val codeFragment: KtCodeFragment, private val sourcePositi
|
|||||||
evaluationException("Parameter evaluation is not supported for '\$default' methods")
|
evaluationException("Parameter evaluation is not supported for '\$default' methods")
|
||||||
} else {
|
} else {
|
||||||
status.error(EvaluationError.CannotFindVariable)
|
status.error(EvaluationError.CannotFindVariable)
|
||||||
|
evaluationException("Cannot find local variable '$name' with type " + asmType.className)
|
||||||
throw VariableFinder.variableNotFound(variableFinder.context, buildString {
|
|
||||||
append("Cannot find local variable: name = '").append(name).append("', type = ").append(asmType.className)
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
-30
@@ -38,36 +38,6 @@ class VariableFinder(val context: ExecutionContext) {
|
|||||||
private val USE_UNSAFE_FALLBACK: Boolean
|
private val USE_UNSAFE_FALLBACK: Boolean
|
||||||
get() = true
|
get() = true
|
||||||
|
|
||||||
fun variableNotFound(context: ExecutionContext, message: String): Exception {
|
|
||||||
val frameProxy = context.frameProxy
|
|
||||||
val location = frameProxy.safeLocation()
|
|
||||||
val scope = context.debugProcess.searchScope
|
|
||||||
|
|
||||||
val locationText = location?.run { "Location: ${sourceName()}:${lineNumber()}" } ?: "No location available"
|
|
||||||
|
|
||||||
val sourceName = location?.sourceName()
|
|
||||||
val declaringTypeName = location?.declaringType()?.name()?.replace('.', '/')?.let { JvmClassName.byInternalName(it) }
|
|
||||||
|
|
||||||
val sourceFile = if (sourceName != null && declaringTypeName != null) {
|
|
||||||
DebuggerUtils.findSourceFileForClassIncludeLibrarySources(context.project, scope, declaringTypeName, sourceName, location)
|
|
||||||
} else {
|
|
||||||
null
|
|
||||||
}
|
|
||||||
|
|
||||||
val sourceFileText = runReadAction { sourceFile?.text }
|
|
||||||
|
|
||||||
if (sourceName != null && sourceFileText != null) {
|
|
||||||
val attachments = mergeAttachments(
|
|
||||||
Attachment(sourceName, sourceFileText),
|
|
||||||
Attachment("location.txt", locationText)
|
|
||||||
)
|
|
||||||
|
|
||||||
LOG.error(message, attachments)
|
|
||||||
}
|
|
||||||
|
|
||||||
return EvaluateExceptionUtil.createEvaluateException(message)
|
|
||||||
}
|
|
||||||
|
|
||||||
private fun getCapturedVariableNameRegex(capturedName: String): Regex {
|
private fun getCapturedVariableNameRegex(capturedName: String): Regex {
|
||||||
val escapedName = Regex.escape(capturedName)
|
val escapedName = Regex.escape(capturedName)
|
||||||
val escapedSuffix = Regex.escape(INLINE_TRANSFORMATION_SUFFIX)
|
val escapedSuffix = Regex.escape(INLINE_TRANSFORMATION_SUFFIX)
|
||||||
|
|||||||
+2
-2
@@ -16,7 +16,7 @@ fun main(args: Array<String>) {
|
|||||||
|
|
||||||
fun myLocalFun3() {
|
fun myLocalFun3() {
|
||||||
// EXPRESSION: myLocalFun1() + 1
|
// EXPRESSION: myLocalFun1() + 1
|
||||||
// RESULT: java.lang.AssertionError : Cannot find local variable: name = 'myLocalFun1', type = kotlin.jvm.functions.Function0
|
// RESULT: Cannot find local variable 'myLocalFun1' with type kotlin.jvm.functions.Function0
|
||||||
//Breakpoint!
|
//Breakpoint!
|
||||||
myLocalFun1() + 1
|
myLocalFun1() + 1
|
||||||
}
|
}
|
||||||
@@ -56,7 +56,7 @@ fun main(args: Array<String>) {
|
|||||||
i = 1
|
i = 1
|
||||||
fun myLocalFun7() {
|
fun myLocalFun7() {
|
||||||
// EXPRESSION: myLocalFun6() + 1
|
// EXPRESSION: myLocalFun6() + 1
|
||||||
// RESULT: java.lang.AssertionError : Cannot find local variable: name = 'myLocalFun6', type = kotlin.jvm.functions.Function0
|
// RESULT: Cannot find local variable 'myLocalFun6' with type kotlin.jvm.functions.Function0
|
||||||
//Breakpoint!
|
//Breakpoint!
|
||||||
myLocalFun6() + 1
|
myLocalFun6() + 1
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user