Skip to content

Commit

Permalink
Display breakpoint status in IDEA
Browse files Browse the repository at this point in the history
(cherry picked from commit c84dcd3)
  • Loading branch information
konsoletyper committed Jul 4, 2017
1 parent ebfeec9 commit c4cc715
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -24,6 +25,7 @@
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;
Expand Down Expand Up @@ -70,14 +72,17 @@ public void paused(Breakpoint breakpoint) {

@Override
public void breakpointStatusChanged(Breakpoint breakpoint) {
updateBreakpointStatus(breakpoint);
}

@Override
public void attached() {
updateAllBreakpoints();
}

@Override
public void detached() {
updateAllBreakpoints();
}
});

Expand Down Expand Up @@ -145,6 +150,39 @@ private void handlePaused() {
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ public void registerBreakpoint(@NotNull B breakpoint) {
Breakpoint innerBreakpoint = innerDebugger.createBreakpoint(path, breakpoint.getLine() + 1);
breakpoint.putUserData(TeaVMDebugProcess.INNER_BREAKPOINT_KEY, innerBreakpoint);
debugProcess.breakpointMap.put(innerBreakpoint, breakpoint);
debugProcess.updateBreakpointStatus(innerBreakpoint);
}

@Nullable
Expand Down

0 comments on commit c4cc715

Please sign in to comment.