[debugger] Introduce a new method isEvaluationPossibleInCurrentCommand.

In this commit 2de5dc57 the logic of isEvaluationPossible method was changed, though it's sometimes necessary to only check whether evaluation will be possible on this context.

GitOrigin-RevId: 18fbfda949fde8d7ae0a43c38342077242d3bd1d
This commit is contained in:
Maria Sokolova
2025-02-19 15:18:11 +01:00
committed by intellij-monorepo-bot
parent 1e736d5f1e
commit a8f9784663
5 changed files with 9 additions and 5 deletions

View File

@@ -2810,8 +2810,12 @@ public abstract class DebugProcessImpl extends UserDataHolderBase implements Deb
&& suspendContextCommand.getSuspendContext() == suspendContext;
}
public boolean isEvaluationPossibleInCurrentCommand(SuspendContextImpl suspendContext) {
return isInSuspendCommand(suspendContext) && isEvaluationPossible(suspendContext);
}
public boolean isEvaluationPossible(SuspendContextImpl suspendContext) {
return isInSuspendCommand(suspendContext) && mySuspendManager.hasPausedContext(suspendContext);
return mySuspendManager.hasPausedContext(suspendContext);
}
public void startWatchingMethodReturn(ThreadReferenceProxyImpl thread) {

View File

@@ -168,7 +168,7 @@ public final class EvaluationContextImpl extends UserDataHolderBase implements E
}
public boolean isEvaluationPossible() {
return getSuspendContext().getDebugProcess().isEvaluationPossible(getSuspendContext());
return getSuspendContext().getDebugProcess().isEvaluationPossibleInCurrentCommand(getSuspendContext());
}
@Contract(pure = true)

View File

@@ -44,7 +44,7 @@ internal fun getIdeState(evaluationContext: EvaluationContext): IdeState? {
val supportClass = findClassOrNull(evaluationContext, SUPPORT_CLASS_FQN) as? ClassType ?: return null
val debugProcess = evaluationContext.debugProcess as? DebugProcessImpl ?: return null
val suspendContext = evaluationContext.suspendContext as? SuspendContextImpl ?: return null
if (!debugProcess.isEvaluationPossible(suspendContext)) return null
if (!debugProcess.isEvaluationPossibleInCurrentCommand(suspendContext)) return null
val state = evaluationContext.computeAndKeep {
DebuggerUtilsImpl.invokeClassMethod(evaluationContext, supportClass, GET_STATE_METHOD_NAME, GET_STATE_METHOD_SIGNATURE, emptyList()) as? ObjectReference
} ?: return null

View File

@@ -125,7 +125,7 @@ private class SessionThreadsData() {
* @see com.intellij.openapi.progress.Cancellation.isInNonCancelableSection
*/
private fun initializeThreadState(suspendContext: SuspendContextImpl): ObjectReference? {
if (!suspendContext.debugProcess.isEvaluationPossible(suspendContext)) return null
if (!suspendContext.debugProcess.isEvaluationPossibleInCurrentCommand(suspendContext)) return null
val evaluationContext = EvaluationContextImpl(suspendContext, suspendContext.frameProxy)
val cancellationClass = findClassOrNull(evaluationContext, CANCELLATION_FQN) as? ClassType ?: return null
val method = DebuggerUtilsImpl.findMethod(cancellationClass,

View File

@@ -109,7 +109,7 @@ fun ThreadReferenceProxyImpl.supportsEvaluation(): Boolean =
threadReference?.isSuspended ?: false
private fun SuspendContextImpl.supportsEvaluation() =
debugProcess.isEvaluationPossible(this) || isUnitTestMode()
debugProcess.isEvaluationPossibleInCurrentCommand(this) || isUnitTestMode()
fun threadAndContextSupportsEvaluation(suspendContext: SuspendContextImpl, frameProxy: StackFrameProxyImpl?): Boolean {
DebuggerManagerThreadImpl.assertIsManagerThread()