Debugger: Log evaluation status from Java contexts

IntelliJ doesn't call KotlinDebuggerEvaluator from Java contexts; instead, it calls JavaDebuggerEvaluator.
Unfortunately, there seems to be no way to figure out the exact evaluation type for Java contexts. However, we can at least log the evaluation status itself.
This commit is contained in:
Yan Zhulanow
2019-10-16 17:59:05 +09:00
parent 6bf15b6d37
commit 2cb055a3bd
2 changed files with 10 additions and 2 deletions
@@ -18,6 +18,7 @@ package org.jetbrains.kotlin.idea.debugger.evaluate
import com.intellij.debugger.DebuggerManagerEx
import com.intellij.debugger.engine.DebugProcessImpl
import com.intellij.debugger.engine.JavaDebuggerEvaluator
import com.intellij.debugger.engine.evaluation.CodeFragmentFactory
import com.intellij.debugger.engine.evaluation.TextWithImports
import com.intellij.debugger.engine.events.DebuggerCommandImpl
@@ -146,10 +147,16 @@ class KotlinCodeFragmentFactory : CodeFragmentFactory() {
DebugLabelPropertyDescriptorProvider(codeFragment, debugProcess).supplyDebugLabels()
@Suppress("MoveVariableDeclarationIntoWhen")
val evaluator = debugProcess.session.xDebugSession?.currentStackFrame?.evaluator
if (evaluator is KotlinDebuggerEvaluator) {
codeFragment.putUserData(EVALUATION_TYPE, evaluator.getType(item))
val evaluationType = when (evaluator) {
is KotlinDebuggerEvaluator -> evaluator.getType(item)
is JavaDebuggerEvaluator -> KotlinDebuggerEvaluator.EvaluationType.FROM_JAVA
else -> KotlinDebuggerEvaluator.EvaluationType.UNKNOWN
}
codeFragment.putUserData(EVALUATION_TYPE, evaluationType)
}
private fun getDebugProcess(project: Project, context: PsiElement?): DebugProcessImpl? {
@@ -72,6 +72,7 @@ class KotlinDebuggerEvaluator(
WATCH(WatchNodeImpl::class.java),
WINDOW(EvaluatingExpressionRootNode::class.java),
POPUP(XValueHint::class.java),
FROM_JAVA(null),
UNKNOWN(null);
}
}