diff --git a/platform/script-debugger/backend/src/SuspendContext.kt b/platform/script-debugger/backend/src/SuspendContext.kt index 3f78f89cfc97..8d6ac42af478 100755 --- a/platform/script-debugger/backend/src/SuspendContext.kt +++ b/platform/script-debugger/backend/src/SuspendContext.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -18,7 +18,6 @@ package org.jetbrains.debugger import com.intellij.util.Consumer import org.jetbrains.concurrency.Promise import org.jetbrains.debugger.values.ValueManager -import org.jetbrains.debugger.values.VmAwareValueManager /** * An object that matches the execution state of the VM while suspended @@ -27,6 +26,7 @@ interface SuspendContext { val state: SuspendState val script: Script? + get() = topFrame?.let { vm.scriptManager.getScript(it) } /** * @return the current exception state, or `null` if current state is @@ -56,12 +56,16 @@ interface SuspendContext { val valueManager: ValueManager + val vm: Vm + get() = throw UnsupportedOperationException() + val workerId: String? + get() = null } abstract class ContextDependentAsyncResultConsumer(private val context: SuspendContext<*>) : Consumer { override final fun consume(result: T) { - val vm = (context.valueManager as VmAwareValueManager<*>).vm + val vm = context.vm if (vm.attachStateManager.isAttached && !vm.suspendContextManager.isContextObsolete(context)) { consume(result, vm) } @@ -71,7 +75,7 @@ abstract class ContextDependentAsyncResultConsumer(private val context: Suspe } -inline fun Promise.done(context: SuspendContext<*>, crossinline handler: (result: T) -> Unit) = (this as Promise).done(object : ContextDependentAsyncResultConsumer(context) { +inline fun Promise.done(context: SuspendContext<*>, crossinline handler: (result: T) -> Unit) = (this).done(object : ContextDependentAsyncResultConsumer(context) { override fun consume(result: T, vm: Vm) = handler(result) }) diff --git a/platform/script-debugger/backend/src/SuspendContextBase.kt b/platform/script-debugger/backend/src/SuspendContextBase.kt index 6e8bc21ef0e9..bc9febc7a890 100644 --- a/platform/script-debugger/backend/src/SuspendContextBase.kt +++ b/platform/script-debugger/backend/src/SuspendContextBase.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -15,18 +15,7 @@ */ package org.jetbrains.debugger -import org.jetbrains.debugger.values.ValueManager -import org.jetbrains.debugger.values.VmAwareValueManager - -abstract class SuspendContextBase(override final val valueManager: VALUE_MANAGER, protected val explicitPaused: Boolean) : SuspendContext { +abstract class SuspendContextBase(protected val explicitPaused: Boolean) : SuspendContext { override val state: SuspendState get() = if (exceptionData == null) (if (explicitPaused) SuspendState.PAUSED else SuspendState.NORMAL) else SuspendState.EXCEPTION - - override val script: Script? - get() { - val topFrame = topFrame - return if (topFrame == null || valueManager !is VmAwareValueManager<*>) null else valueManager.vm.scriptManager.getScript(topFrame) - } - - override val workerId: String? = null } \ No newline at end of file diff --git a/platform/script-debugger/backend/src/SuspendContextManager.kt b/platform/script-debugger/backend/src/SuspendContextManager.kt index 2822370bdf00..24ae81a87c81 100644 --- a/platform/script-debugger/backend/src/SuspendContextManager.kt +++ b/platform/script-debugger/backend/src/SuspendContextManager.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -68,7 +68,6 @@ enum class StepAction { */ IN, - /** * Step into first scheduled async handler. * @see Chrome debugger suggestion diff --git a/platform/script-debugger/backend/src/SuspendContextManagerBase.kt b/platform/script-debugger/backend/src/SuspendContextManagerBase.kt index 99b5f6a17773..c075dbad3e73 100644 --- a/platform/script-debugger/backend/src/SuspendContextManagerBase.kt +++ b/platform/script-debugger/backend/src/SuspendContextManagerBase.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -22,7 +22,7 @@ import org.jetbrains.concurrency.resolvedPromise import java.util.* import java.util.concurrent.atomic.AtomicReference -abstract class SuspendContextManagerBase, CALL_FRAME : CallFrame> : SuspendContextManager { +abstract class SuspendContextManagerBase, CALL_FRAME : CallFrame> : SuspendContextManager { val contextRef = AtomicReference() val threadSuspendContexts: MutableMap> = Collections.synchronizedMap(LinkedHashMap>()) @@ -56,7 +56,7 @@ abstract class SuspendContextManagerBase): Promise<*> { val context = contextOrFail - (promise as Promise).done { contextDismissed(context) } + promise.done { contextDismissed(context) } return promise } @@ -79,7 +79,7 @@ abstract class SuspendContextManagerBase @@ -98,7 +98,7 @@ abstract class SuspendContextManagerBase, CALL_FRAME : CallFrame>( +data class JSExecutionStackSuspendContext, CALL_FRAME : CallFrame>( val suspendContext: T, val script: Script?, val additionalData: Any? diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java index ca8c94602c6b..764091b57961 100755 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/DebugEventListener.java @@ -26,7 +26,7 @@ public interface DebugEventListener extends EventListener { * breakpoints or a step end). The {@code context} can be used to access the * current backtrace. */ - default void suspended(@NotNull Vm vm, @NotNull SuspendContext context) { + default void suspended(@NotNull SuspendContext context) { } /** diff --git a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.kt b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.kt index 492ca5d054ae..9d41c63f939c 100644 --- a/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.kt +++ b/platform/script-debugger/backend/src/org/jetbrains/debugger/values/ValueManager.kt @@ -1,5 +1,5 @@ /* - * Copyright 2000-2015 JetBrains s.r.o. + * Copyright 2000-2016 JetBrains s.r.o. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -19,7 +19,6 @@ import org.jetbrains.concurrency.AsyncPromise import org.jetbrains.concurrency.Obsolescent import org.jetbrains.concurrency.Promise import org.jetbrains.concurrency.rejectedPromise -import org.jetbrains.debugger.Vm import java.util.concurrent.atomic.AtomicInteger /** @@ -48,8 +47,7 @@ abstract class ValueManager() : Obsolescent { companion object { val OBSOLETE_CONTEXT_PROMISE = rejectedPromise(AsyncPromise.OBSOLETE_ERROR) + @Suppress("CAST_NEVER_SUCCEEDS") fun reject() = OBSOLETE_CONTEXT_PROMISE as Promise } -} - -abstract class VmAwareValueManager(final val vm: VM) : ValueManager() \ No newline at end of file +} \ No newline at end of file diff --git a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt index 5b5a504456df..c968cf39ffa8 100644 --- a/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt +++ b/platform/script-debugger/debugger-ui/src/org/jetbrains/debugger/DebugProcessImpl.kt @@ -162,7 +162,7 @@ abstract class DebugProcessImpl>(session: XDebugSession, } protected fun setOverlay(context: SuspendContext<*>) { - if (context.workerId == null) { + if (context.vm == vm) { vm!!.suspendContextManager.setOverlayMessage("Paused in debugger") } }