use of com.intellij.debugger.ui.breakpoints.Breakpoint in project intellij-community by JetBrains.
the class ToggleFieldBreakpointAction method update.
@Override
public void update(AnActionEvent event) {
SourcePosition place = getPlace(event);
boolean toEnable = place != null;
Presentation presentation = event.getPresentation();
if (ActionPlaces.PROJECT_VIEW_POPUP.equals(event.getPlace()) || ActionPlaces.STRUCTURE_VIEW_POPUP.equals(event.getPlace()) || ActionPlaces.FAVORITES_VIEW_POPUP.equals(event.getPlace())) {
presentation.setVisible(toEnable);
} else if (DebuggerAction.isContextView(event)) {
presentation.setText(DebuggerBundle.message("action.add.field.watchpoint.text"));
Project project = event.getData(CommonDataKeys.PROJECT);
if (project != null && place != null) {
Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
if (document != null) {
final int offset = place.getOffset();
final BreakpointManager breakpointManager = (DebuggerManagerEx.getInstanceEx(project)).getBreakpointManager();
final Breakpoint fieldBreakpoint = offset >= 0 ? breakpointManager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
if (fieldBreakpoint != null) {
presentation.setEnabled(false);
return;
}
}
}
}
presentation.setVisible(toEnable);
}
use of com.intellij.debugger.ui.breakpoints.Breakpoint in project intellij-community by JetBrains.
the class ToggleFieldBreakpointAction method actionPerformed.
@Override
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
final SourcePosition place = getPlace(e);
if (place != null) {
Document document = PsiDocumentManager.getInstance(project).getDocument(place.getFile());
if (document != null) {
DebuggerManagerEx debuggerManager = DebuggerManagerEx.getInstanceEx(project);
BreakpointManager manager = debuggerManager.getBreakpointManager();
final int offset = place.getOffset();
final Breakpoint breakpoint = offset >= 0 ? manager.findBreakpoint(document, offset, FieldBreakpoint.CATEGORY) : null;
if (breakpoint == null) {
FieldBreakpoint fieldBreakpoint = manager.addFieldBreakpoint(document, offset);
if (fieldBreakpoint != null) {
if (DebuggerAction.isContextView(e)) {
final DebuggerTreeNodeImpl selectedNode = DebuggerAction.getSelectedNode(e.getDataContext());
if (selectedNode != null && selectedNode.getDescriptor() instanceof FieldDescriptorImpl) {
ObjectReference object = ((FieldDescriptorImpl) selectedNode.getDescriptor()).getObject();
if (object != null) {
long id = object.uniqueID();
InstanceFilter[] instanceFilters = new InstanceFilter[] { InstanceFilter.create(Long.toString(id)) };
fieldBreakpoint.setInstanceFilters(instanceFilters);
fieldBreakpoint.setInstanceFiltersEnabled(true);
}
}
}
final Editor editor = CommonDataKeys.EDITOR.getData(e.getDataContext());
if (editor != null) {
manager.editBreakpoint(fieldBreakpoint, editor);
}
}
} else {
manager.removeBreakpoint(breakpoint);
}
}
}
}
use of com.intellij.debugger.ui.breakpoints.Breakpoint in project android by JetBrains.
the class InstantRunManager method refreshDebugger.
private void refreshDebugger(@NotNull String packageName) {
// First we reapply the breakpoints on the new code, otherwise the breakpoints
// remain set on the old classes and will never be hit again.
ApplicationManager.getApplication().runReadAction(new Runnable() {
@Override
public void run() {
DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
if (!debugger.getSessions().isEmpty()) {
List<Breakpoint> breakpoints = debugger.getBreakpointManager().getBreakpoints();
for (Breakpoint breakpoint : breakpoints) {
if (breakpoint.isEnabled()) {
breakpoint.setEnabled(false);
breakpoint.setEnabled(true);
}
}
}
}
});
// Now we refresh the call-stacks and the variable panes.
DebuggerManagerEx debugger = DebuggerManagerEx.getInstanceEx(myProject);
for (final DebuggerSession session : debugger.getSessions()) {
Client client = session.getProcess().getProcessHandler().getUserData(AndroidSessionInfo.ANDROID_DEBUG_CLIENT);
if (client != null && client.isValid() && StringUtil.equals(packageName, client.getClientData().getClientDescription())) {
session.getProcess().getManagerThread().invoke(new DebuggerCommandImpl() {
@Override
protected void action() throws Exception {
DebuggerContextImpl context = session.getContextManager().getContext();
SuspendContextImpl suspendContext = context.getSuspendContext();
if (suspendContext != null) {
XExecutionStack stack = suspendContext.getActiveExecutionStack();
if (stack != null) {
((JavaExecutionStack) stack).initTopFrame();
}
}
ApplicationManager.getApplication().invokeLater(new Runnable() {
@Override
public void run() {
session.refresh(false);
XDebugSession xSession = session.getXDebugSession();
if (xSession != null) {
xSession.resume();
}
}
});
}
});
}
}
}
use of com.intellij.debugger.ui.breakpoints.Breakpoint in project intellij-community by JetBrains.
the class ToggleMethodBreakpointAction method actionPerformed.
public void actionPerformed(AnActionEvent e) {
Project project = e.getData(CommonDataKeys.PROJECT);
if (project == null) {
return;
}
DebuggerManagerEx debugManager = DebuggerManagerEx.getInstanceEx(project);
if (debugManager == null) {
return;
}
final BreakpointManager manager = debugManager.getBreakpointManager();
final PlaceInDocument place = getPlace(e);
if (place != null && DocumentUtil.isValidOffset(place.getOffset(), place.getDocument())) {
Breakpoint breakpoint = manager.findBreakpoint(place.getDocument(), place.getOffset(), MethodBreakpoint.CATEGORY);
if (breakpoint == null) {
manager.addMethodBreakpoint(place.getDocument(), place.getDocument().getLineNumber(place.getOffset()));
} else {
manager.removeBreakpoint(breakpoint);
}
}
}
use of com.intellij.debugger.ui.breakpoints.Breakpoint in project intellij-community by JetBrains.
the class DebugProcessEvents method processLocatableEvent.
private void processLocatableEvent(final SuspendContextImpl suspendContext, final LocatableEvent event) {
ThreadReference thread = event.thread();
//LOG.assertTrue(thread.isSuspended());
preprocessEvent(suspendContext, thread);
//we use schedule to allow processing other events during processing this one
//this is especially necessary if a method is breakpoint condition
getManagerThread().schedule(new SuspendContextCommandImpl(suspendContext) {
@Override
public void contextAction() throws Exception {
final SuspendManager suspendManager = getSuspendManager();
SuspendContextImpl evaluatingContext = SuspendManagerUtil.getEvaluatingContext(suspendManager, suspendContext.getThread());
if (evaluatingContext != null && !DebuggerSession.enableBreakpointsDuringEvaluation()) {
// is inside evaluation, so ignore any breakpoints
suspendManager.voteResume(suspendContext);
return;
}
final LocatableEventRequestor requestor = (LocatableEventRequestor) getRequestsManager().findRequestor(event.request());
boolean resumePreferred = requestor != null && DebuggerSettings.SUSPEND_NONE.equals(requestor.getSuspendPolicy());
boolean requestHit;
try {
requestHit = (requestor != null) && requestor.processLocatableEvent(this, event);
} catch (final LocatableEventRequestor.EventProcessingException ex) {
if (LOG.isDebugEnabled()) {
LOG.debug(ex.getMessage());
}
final boolean[] considerRequestHit = new boolean[] { true };
DebuggerInvocationUtil.invokeAndWait(getProject(), () -> {
final String displayName = requestor instanceof Breakpoint ? ((Breakpoint) requestor).getDisplayName() : requestor.getClass().getSimpleName();
final String message = DebuggerBundle.message("error.evaluating.breakpoint.condition.or.action", displayName, ex.getMessage());
considerRequestHit[0] = Messages.showYesNoDialog(getProject(), message, ex.getTitle(), Messages.getQuestionIcon()) == Messages.YES;
}, ModalityState.NON_MODAL);
requestHit = considerRequestHit[0];
resumePreferred = !requestHit;
}
if (requestHit && requestor instanceof Breakpoint) {
// if requestor is a breakpoint and this breakpoint was hit, no matter its suspend policy
ApplicationManager.getApplication().runReadAction(() -> {
XDebugSession session = getSession().getXDebugSession();
if (session != null) {
XBreakpoint breakpoint = ((Breakpoint) requestor).getXBreakpoint();
if (breakpoint != null) {
((XDebugSessionImpl) session).processDependencies(breakpoint);
}
}
});
}
if (!requestHit || resumePreferred) {
suspendManager.voteResume(suspendContext);
} else {
if (myReturnValueWatcher != null) {
myReturnValueWatcher.disable();
}
//if (suspendContext.getSuspendPolicy() == EventRequest.SUSPEND_ALL) {
// // there could be explicit resume as a result of call to voteSuspend()
// // e.g. when breakpoint was considered invalid, in that case the filter will be applied _after_
// // resuming and all breakpoints in other threads will be ignored.
// // As resume() implicitly cleares the filter, the filter must be always applied _before_ any resume() action happens
// myBreakpointManager.applyThreadFilter(DebugProcessEvents.this, event.thread());
//}
suspendManager.voteSuspend(suspendContext);
showStatusText(DebugProcessEvents.this, event);
}
}
});
}
Aggregations