Display breakpoint status in IDEA

This commit is contained in:
Alexey Andreev 2017-07-04 07:18:02 +03:00
parent 1581345e17
commit c84dcd366e
2 changed files with 39 additions and 0 deletions

View File

@ -16,6 +16,7 @@
package org.teavm.idea.debug; package org.teavm.idea.debug;
import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType; import com.intellij.debugger.ui.breakpoints.JavaLineBreakpointType;
import com.intellij.icons.AllIcons;
import com.intellij.openapi.extensions.ExtensionPoint; import com.intellij.openapi.extensions.ExtensionPoint;
import com.intellij.openapi.extensions.Extensions; import com.intellij.openapi.extensions.Extensions;
import com.intellij.openapi.util.Key; import com.intellij.openapi.util.Key;
@ -24,6 +25,7 @@ import com.intellij.xdebugger.XDebugSession;
import com.intellij.xdebugger.XSourcePosition; import com.intellij.xdebugger.XSourcePosition;
import com.intellij.xdebugger.breakpoints.XBreakpoint; import com.intellij.xdebugger.breakpoints.XBreakpoint;
import com.intellij.xdebugger.breakpoints.XBreakpointHandler; import com.intellij.xdebugger.breakpoints.XBreakpointHandler;
import com.intellij.xdebugger.breakpoints.XLineBreakpoint;
import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider; import com.intellij.xdebugger.evaluation.XDebuggerEditorsProvider;
import com.intellij.xdebugger.frame.XSuspendContext; import com.intellij.xdebugger.frame.XSuspendContext;
import java.util.ArrayList; import java.util.ArrayList;
@ -70,14 +72,17 @@ public class TeaVMDebugProcess extends XDebugProcess {
@Override @Override
public void breakpointStatusChanged(Breakpoint breakpoint) { public void breakpointStatusChanged(Breakpoint breakpoint) {
updateBreakpointStatus(breakpoint);
} }
@Override @Override
public void attached() { public void attached() {
updateAllBreakpoints();
} }
@Override @Override
public void detached() { public void detached() {
updateAllBreakpoints();
} }
}); });
@ -145,6 +150,39 @@ public class TeaVMDebugProcess extends XDebugProcess {
getSession().positionReached(new TeaVMSuspendContext(innerDebugger, getSession().getProject())); 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 @NotNull
@Override @Override
public XBreakpointHandler<?>[] getBreakpointHandlers() { public XBreakpointHandler<?>[] getBreakpointHandlers() {

View File

@ -66,6 +66,7 @@ public class TeaVMLineBreakpointHandler<B extends XLineBreakpoint<?>> extends XB
Breakpoint innerBreakpoint = innerDebugger.createBreakpoint(path, breakpoint.getLine() + 1); Breakpoint innerBreakpoint = innerDebugger.createBreakpoint(path, breakpoint.getLine() + 1);
breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, innerBreakpoint); breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, innerBreakpoint);
debugProcess.breakpointMap.put(innerBreakpoint, breakpoint); debugProcess.breakpointMap.put(innerBreakpoint, breakpoint);
debugProcess.updateBreakpointStatus(innerBreakpoint);
} }
@Nullable @Nullable