From c84dcd366e674a5d09aae74cdccee37ae6fa78e8 Mon Sep 17 00:00:00 2001 From: Alexey Andreev Date: Tue, 4 Jul 2017 07:18:02 +0300 Subject: [PATCH] Display breakpoint status in IDEA --- .../teavm/idea/debug/TeaVMDebugProcess.java | 38 +++++++++++++++++++ .../debug/TeaVMLineBreakpointHandler.java | 1 + 2 files changed, 39 insertions(+) diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java index f3e0e50e4..1abe59711 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMDebugProcess.java @@ -16,6 +16,7 @@ package org.teavm.idea.debug; import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType; +import com.intellij.icons.AllIcons; import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.util.Key; @@ -24,6 +25,7 @@ import com.intellij.xdebugger.XDebugSession; import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpointHandler; +import com.intellij.xdebugger.breakpoints.XLineBreakpoint; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.frame.XSuspendContext; import java.util.ArrayList; @@ -70,14 +72,17 @@ public class TeaVMDebugProcess extends XDebugProcess { @Override public void breakpointStatusChanged(Breakpoint breakpoint) { + updateBreakpointStatus(breakpoint); } @Override public void attached() { + updateAllBreakpoints(); } @Override public void detached() { + updateAllBreakpoints(); } }); @@ -145,6 +150,39 @@ public class TeaVMDebugProcess extends XDebugProcess { getSession().positionReached(new TeaVMSuspendContext(innerDebugger, getSession().getProject())); } + @Override + public boolean checkCanPerformCommands() { + return innerDebugger.isSuspended() && innerDebugger.isAttached(); + } + + void updateBreakpointStatus(Breakpoint breakpoint) { + XBreakpoint xBreakpoint = breakpointMap.get(breakpoint); + if (xBreakpoint instanceof XLineBreakpoint) { + XLineBreakpoint xLineBreakpoint = (XLineBreakpoint) xBreakpoint; + if (!innerDebugger.isAttached()) { + getSession().updateBreakpointPresentation(xLineBreakpoint, null, + null); + } else if (breakpoint.isValid()) { + getSession().updateBreakpointPresentation(xLineBreakpoint, AllIcons.Debugger.Db_verified_breakpoint, + null); + } else { + getSession().updateBreakpointPresentation(xLineBreakpoint, AllIcons.Debugger.Db_invalid_breakpoint, + "Could not set breakpoint in remote process"); + } + } + } + + @Override + public String getCurrentStateMessage() { + return !innerDebugger.isAttached() ? "Detached" : super.getCurrentStateMessage(); + } + + private void updateAllBreakpoints() { + for (Breakpoint breakpoint : breakpointMap.keySet().toArray(new Breakpoint[0])) { + updateBreakpointStatus(breakpoint); + } + } + @NotNull @Override public XBreakpointHandler[] getBreakpointHandlers() { diff --git a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java index 3aab58474..4c6374559 100644 --- a/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java +++ b/tools/idea/plugin/src/main/java/org/teavm/idea/debug/TeaVMLineBreakpointHandler.java @@ -66,6 +66,7 @@ public class TeaVMLineBreakpointHandler> extends XB Breakpoint innerBreakpoint = innerDebugger.createBreakpoint(path, breakpoint.getLine() + 1); breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, innerBreakpoint); debugProcess.breakpointMap.put(innerBreakpoint, breakpoint); + debugProcess.updateBreakpointStatus(innerBreakpoint); } @Nullable