Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@ abstract class AbstractDebuggerAction(
override var enabled = true
override var icon: Drawable? = null

protected val debugClient: IDEDebugClientImpl
get() = IDEDebugClientImpl.requireInstance()
protected val debugClient: IDEDebugClientImpl?
get() = IDEDebugClientImpl.getInstance()

protected open fun checkEnabled(data: ActionData): Boolean = debugClient.isVmConnected()
protected open fun checkEnabled(data: ActionData): Boolean = debugClient?.isVmConnected() == true

override fun prepare(data: ActionData) {
super.prepare(data)

icon = ContextCompat.getDrawable(data.requireContext(), iconRes)
enabled = checkEnabled(data)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ abstract class AbstractStepAction(
@DrawableRes iconRes: Int
): AbstractDebuggerAction(iconRes) {

override fun checkEnabled(data: ActionData): Boolean =
debugClient.connectionState >= DebuggerConnectionState.AWAITING_BREAKPOINT
}
override fun checkEnabled(data: ActionData): Boolean {
val client = debugClient ?: return false
return client.connectionState >= DebuggerConnectionState.AWAITING_BREAKPOINT
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class KillVmAction(
override var tooltipTag = TooltipTag.DEBUGGER_ACTION_KILL

override suspend fun execAction(data: ActionData) {
debugClient.killVm()
debugClient?.killVm()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class StepIntoAction(
override var tooltipTag = TooltipTag.DEBUGGER_ACTION_STEP_INTO

override suspend fun execAction(data: ActionData) {
debugClient.stepInto()
debugClient?.stepInto()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class StepOutAction(
override var tooltipTag = TooltipTag.DEBUGGER_ACTION_STEP_OUT

override suspend fun execAction(data: ActionData) {
debugClient.stepOut()
debugClient?.stepOut()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ class StepOverAction(
override var tooltipTag = TooltipTag.DEBUGGER_ACTION_STEP_OVER

override suspend fun execAction(data: ActionData) {
debugClient.stepOver()
debugClient?.stepOver()
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class SuspendResumeVmAction(
override fun prepare(data: ActionData) {
super.prepare(data)
val context = data.requireContext()
val isSuspended = debugClient.isVmSuspended()
val isSuspended = debugClient?.isVmSuspended() == true
if (isSuspended) {
label = context.getString(R.string.debugger_resume)
icon = ContextCompat.getDrawable(context, R.drawable.ic_run)
Expand All @@ -33,10 +33,11 @@ class SuspendResumeVmAction(
}

override suspend fun execAction(data: ActionData) {
if (debugClient.isVmSuspended()) {
debugClient.resumeVm()
val client = debugClient ?: return
if (client.isVmSuspended()) {
client.resumeVm()
} else {
debugClient.suspendVm()
client.suspendVm()
}
}
}
}
Loading