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")
|
||||
} else {
|
||||
status.error(EvaluationError.CannotFindVariable)
|
||||
|
||||
throw VariableFinder.variableNotFound(variableFinder.context, buildString {
|
||||
append("Cannot find local variable: name = '").append(name).append("', type = ").append(asmType.className)
|
||||
})
|
||||
evaluationException("Cannot find local variable '$name' with type " + asmType.className)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
-30
@@ -38,36 +38,6 @@ class VariableFinder(val context: ExecutionContext) {
|
||||
private val USE_UNSAFE_FALLBACK: Boolean
|
||||
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 {
|
||||
val escapedName = Regex.escape(capturedName)
|
||||
val escapedSuffix = Regex.escape(INLINE_TRANSFORMATION_SUFFIX)
|
||||
|
||||
+2
-2
@@ -16,7 +16,7 @@ fun main(args: Array<String>) {
|
||||
|
||||
fun myLocalFun3() {
|
||||
// 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!
|
||||
myLocalFun1() + 1
|
||||
}
|
||||
@@ -56,7 +56,7 @@ fun main(args: Array<String>) {
|
||||
i = 1
|
||||
fun myLocalFun7() {
|
||||
// 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!
|
||||
myLocalFun6() + 1
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user