com.intellij.xdebugger.breakpoints.XBreakpoint Java Examples

The following examples show how to use com.intellij.xdebugger.breakpoints.XBreakpoint. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: XBreakpointsTestCase.java    From consulo with Apache License 2.0 6 votes vote down vote up
protected List<XBreakpoint<?>> getAllBreakpoints() {
  final XBreakpointBase<?,?,?>[] breakpoints = myBreakpointManager.getAllBreakpoints();
  final List<XBreakpoint<?>> result = new ArrayList<XBreakpoint<?>>();
  for (XBreakpointBase<?, ?, ?> breakpoint : breakpoints) {
    final XBreakpointType type = breakpoint.getType();
    if (type instanceof MySimpleBreakpointType || type instanceof MyLineBreakpointType) {
      result.add(breakpoint);
    }
  }
  Collections.sort(result, new Comparator<XBreakpoint<?>>() {
    @Override
    public int compare(XBreakpoint<?> o1, XBreakpoint<?> o2) {
      return StringUtil.compare(((MyBreakpointProperties)o1.getProperties()).myOption,
                                ((MyBreakpointProperties)o2.getProperties()).myOption, true);
    }
  });
  return result;
}
 
Example #2
Source File: XBreakpointManagerTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testAddRemove() {
  XLineBreakpoint<MyBreakpointProperties> lineBreakpoint =
    myBreakpointManager.addLineBreakpoint(MY_LINE_BREAKPOINT_TYPE, "url", 239, new MyBreakpointProperties("123"));

  XBreakpoint<MyBreakpointProperties> breakpoint = myBreakpointManager.addBreakpoint(MY_SIMPLE_BREAKPOINT_TYPE, new MyBreakpointProperties("abc"));

  assertSameElements(getAllBreakpoints(), breakpoint, lineBreakpoint);
  assertSame(lineBreakpoint, assertOneElement(myBreakpointManager.getBreakpoints(MY_LINE_BREAKPOINT_TYPE)));
  assertSame(breakpoint, getSingleBreakpoint());

  myBreakpointManager.removeBreakpoint(lineBreakpoint);
  assertSame(breakpoint, assertOneElement(getAllBreakpoints()));
  assertTrue(myBreakpointManager.getBreakpoints(MY_LINE_BREAKPOINT_TYPE).isEmpty());
  assertSame(breakpoint, getSingleBreakpoint());

  myBreakpointManager.removeBreakpoint(breakpoint);
  assertEmpty(getAllBreakpoints());
  assertTrue(myBreakpointManager.getBreakpoints(MY_SIMPLE_BREAKPOINT_TYPE).isEmpty());
}
 
Example #3
Source File: XDependentBreakpointsTest.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void testSerialize() throws Exception {
  XLineBreakpoint<?> master = createMaster();
  XLineBreakpoint<?> slave = createSlave();
  myDependentBreakpointManager.setMasterBreakpoint(slave, master, true);

  Element element = save();
  myDependentBreakpointManager.clearMasterBreakpoint(slave);
  //System.out.println(JDOMUtil.writeElement(element, SystemProperties.getLineSeparator()));
  load(element);

  List<XBreakpoint<?>> breakpoints = getAllBreakpoints();
  assertEquals(3, breakpoints.size());
  assertEquals("default", ((MyBreakpointProperties)breakpoints.get(0).getProperties()).myOption);
  XLineBreakpoint newMaster = (XLineBreakpoint)breakpoints.get(1);
  XLineBreakpoint newSlave = (XLineBreakpoint)breakpoints.get(2);
  assertEquals("file://master", newMaster.getFileUrl());
  assertEquals("file://slave", newSlave.getFileUrl());
  assertSame(newMaster, myDependentBreakpointManager.getMasterBreakpoint(newSlave));
  assertTrue(myDependentBreakpointManager.isLeaveEnabled(newSlave));
}
 
Example #4
Source File: XDependentBreakpointManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public void setMasterBreakpoint(@Nonnull XBreakpoint<?> slave, @Nonnull XBreakpoint<?> master, boolean leaveEnabled) {
  XDependentBreakpointInfo info = mySlave2Info.get(slave);
  if (info == null) {
    addDependency((XBreakpointBase<?,?,?>)master, (XBreakpointBase<?,?,?>)slave, leaveEnabled);
  }
  else if (info.myMasterBreakpoint == master) {
    info.myLeaveEnabled = leaveEnabled;
  }
  else {
    myMaster2Info.remove(info.myMasterBreakpoint, info);
    info.myMasterBreakpoint = (XBreakpointBase)master;
    info.myLeaveEnabled = leaveEnabled;
    myMaster2Info.put((XBreakpointBase)master, info);
  }
  myDispatcher.getMulticaster().dependencySet(slave, master);
}
 
Example #5
Source File: XDependentBreakpointManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
public XDependentBreakpointManager(final XBreakpointManagerImpl breakpointManager) {
  myBreakpointManager = breakpointManager;
  myDispatcher = EventDispatcher.create(XDependentBreakpointListener.class);
  myBreakpointManager.addBreakpointListener(new XBreakpointAdapter<XBreakpoint<?>>() {
    public void breakpointRemoved(@Nonnull final XBreakpoint<?> breakpoint) {
      XDependentBreakpointInfo info = mySlave2Info.remove(breakpoint);
      if (info != null) {
        myMaster2Info.remove(info.myMasterBreakpoint, info);
      }

      Collection<XDependentBreakpointInfo> infos = myMaster2Info.removeAll((XBreakpointBase)breakpoint);
      if (infos != null) {
        for (XDependentBreakpointInfo breakpointInfo : infos) {
          XDependentBreakpointInfo removed = mySlave2Info.remove(breakpointInfo.mySlaveBreakpoint);
          if (removed != null) {
            myDispatcher.getMulticaster().dependencyCleared(breakpointInfo.mySlaveBreakpoint);
          }
        }
      }
    }
  });
}
 
Example #6
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 6 votes vote down vote up
private void updateBreakpoints(@Nonnull Document document) {
  Collection<XLineBreakpointImpl> breakpoints = myBreakpoints.getKeysByValue(document);
  if (breakpoints == null) {
    return;
  }

  TIntHashSet lines = new TIntHashSet();
  List<XBreakpoint<?>> toRemove = new SmartList<>();
  for (XLineBreakpointImpl breakpoint : breakpoints) {
    breakpoint.updatePosition();
    if (!breakpoint.isValid() || !lines.add(breakpoint.getLine())) {
      toRemove.add(breakpoint);
    }
  }

  removeBreakpoints(toRemove);
}
 
Example #7
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public static ExceptionPauseMode getBreakOnExceptionMode(@NotNull XDebugSession session,
                                                         @Nullable final XBreakpoint<DartExceptionBreakpointProperties> bp) {
  if (session.areBreakpointsMuted()) {
    return ExceptionPauseMode.None;
  }
  if (bp == null) return ExceptionPauseMode.Unhandled; // Default to breaking on unhandled exceptions.
  if (!bp.isEnabled()) return ExceptionPauseMode.None;
  return bp.getProperties().isBreakOnAllExceptions() ? ExceptionPauseMode.All : ExceptionPauseMode.Unhandled;
}
 
Example #8
Source File: XBreakpointManagerTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testSaveChangedDefaultBreakpoint() {
  reload();
  final XBreakpoint<MyBreakpointProperties> breakpoint = getSingleBreakpoint();
  breakpoint.setEnabled(false);

  assertFalse(save().getContent().isEmpty());
  reload();
  assertFalse(getSingleBreakpoint().isEnabled());
}
 
Example #9
Source File: XBreakpointManagerTest.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void testSerialize() {
  XLineBreakpoint<MyBreakpointProperties> breakpoint =
    myBreakpointManager.addLineBreakpoint(MY_LINE_BREAKPOINT_TYPE, "myurl", 239, new MyBreakpointProperties("z1"));
  breakpoint.setCondition("cond");
  breakpoint.setLogExpression("log");
  breakpoint.setSuspendPolicy(SuspendPolicy.NONE);
  breakpoint.setLogMessage(true);
  myBreakpointManager.addBreakpoint(MY_SIMPLE_BREAKPOINT_TYPE, new MyBreakpointProperties("z2"));

  reload();
  List<XBreakpoint<?>> breakpoints = getAllBreakpoints();
  assertEquals("Expected 3 breakpoints, actual: " + breakpoints, 3, breakpoints.size());

  assertTrue(myBreakpointManager.isDefaultBreakpoint(breakpoints.get(0)));
  assertEquals("default", assertInstanceOf(breakpoints.get(0).getProperties(), MyBreakpointProperties.class).myOption);
  assertTrue(breakpoints.get(0).isEnabled());

  XLineBreakpoint lineBreakpoint = assertInstanceOf(breakpoints.get(1), XLineBreakpoint.class);
  assertEquals(239, lineBreakpoint.getLine());
  assertEquals("myurl", lineBreakpoint.getFileUrl());
  assertEquals("z1", assertInstanceOf(lineBreakpoint.getProperties(), MyBreakpointProperties.class).myOption);
  assertEquals("cond", lineBreakpoint.getCondition());
  assertEquals("log", lineBreakpoint.getLogExpression());
  assertTrue(lineBreakpoint.isLogMessage());
  assertEquals(SuspendPolicy.NONE, lineBreakpoint.getSuspendPolicy());

  assertEquals("z2", assertInstanceOf(breakpoints.get(2).getProperties(), MyBreakpointProperties.class).myOption);
  assertEquals(SuspendPolicy.ALL, breakpoints.get(2).getSuspendPolicy());
  assertFalse(breakpoints.get(2).isLogMessage());
}
 
Example #10
Source File: XMasterBreakpointPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
void saveProperties() {
  XBreakpoint<?> masterBreakpoint = (XBreakpoint<?>)myMasterBreakpointChooser.getSelectedBreakpoint();
  if (masterBreakpoint == null) {
    myDependentBreakpointManager.clearMasterBreakpoint(myBreakpoint);
  }
  else {
    myDependentBreakpointManager.setMasterBreakpoint(myBreakpoint, masterBreakpoint, myLeaveEnabledRadioButton.isSelected());
  }
}
 
Example #11
Source File: XMasterBreakpointPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
void loadProperties() {
  XBreakpoint<?> masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(myBreakpoint);
  if (masterBreakpoint != null) {
    myMasterBreakpointChooser.setSelectesBreakpoint(masterBreakpoint);
    myLeaveEnabledRadioButton.setSelected(myDependentBreakpointManager.isLeaveEnabled(myBreakpoint));
  }
  updateAfterBreakpointHitPanel();
}
 
Example #12
Source File: XMasterBreakpointPanel.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public boolean lightVariant(boolean showAllOptions) {
  XBreakpoint<?> masterBreakpoint = myDependentBreakpointManager.getMasterBreakpoint(myBreakpoint);
  if (!showAllOptions && masterBreakpoint == null) {
    myMainPanel.setVisible(false);
    return true;
  }
  return false;
}
 
Example #13
Source File: XBreakpointGroupingByTypeRule.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public XBreakpointTypeGroup getGroup(@Nonnull B b, @Nonnull Collection<XBreakpointTypeGroup> groups) {
  if (b instanceof XBreakpoint) {
    final XBreakpoint breakpoint = (XBreakpoint)b;
    for (XBreakpointTypeGroup group : groups) {
      if (group.getBreakpointType() == breakpoint.getType()) {
        return group;
      }
    }
    return new XBreakpointTypeGroup(breakpoint.getType());
  }
  return null;
}
 
Example #14
Source File: BreakpointsDialog.java    From consulo with Apache License 2.0 5 votes vote down vote up
@RequiredUIAccess
@Override
public void actionPerformed(@Nonnull AnActionEvent e) {
  saveCurrentItem();
  XBreakpoint<?> breakpoint = myType.addBreakpoint(myProject, null);
  if (breakpoint != null) {
    selectBreakpoint(breakpoint);
  }
}
 
Example #15
Source File: XDependentBreakpointManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public List<XBreakpoint<?>> getSlaveBreakpoints(final XBreakpoint<?> breakpoint) {
  Collection<XDependentBreakpointInfo> slaveInfos = myMaster2Info.get((XBreakpointBase)breakpoint);
  if (slaveInfos == null) {
    return Collections.emptyList();
  }
  List<XBreakpoint<?>> breakpoints = new SmartList<XBreakpoint<?>>();
  for (XDependentBreakpointInfo slaveInfo : slaveInfos) {
    breakpoints.add(slaveInfo.mySlaveBreakpoint);
  }
  return breakpoints;
}
 
Example #16
Source File: XDependentBreakpointManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
public void clearMasterBreakpoint(@Nonnull XBreakpoint<?> slave) {
  XDependentBreakpointInfo info = mySlave2Info.remove(slave);
  if (info != null) {
    myMaster2Info.remove(info.myMasterBreakpoint, info);
    myDispatcher.getMulticaster().dependencyCleared(slave);
  }
}
 
Example #17
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void removeBreakpoints(final List<? extends XBreakpoint<?>> toRemove) {
  if (toRemove.isEmpty()) {
    return;
  }

  ApplicationManager.getApplication().runWriteAction(() -> {
    for (XBreakpoint<?> breakpoint : toRemove) {
      XDebuggerManager.getInstance(myProject).getBreakpointManager().removeBreakpoint(breakpoint);
    }
  });
}
 
Example #18
Source File: XBreakpointItem.java    From consulo with Apache License 2.0 5 votes vote down vote up
@Override
public int compareTo(BreakpointItem breakpointItem) {
  if (breakpointItem.getBreakpoint() instanceof XBreakpointBase) {
    return ((XBreakpointBase)myBreakpoint).compareTo((XBreakpoint)breakpointItem.getBreakpoint());
  }
  else {
    return 0;
  }
}
 
Example #19
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public static XBreakpoint<DartExceptionBreakpointProperties> getDefaultExceptionBreakpoint(@NotNull final Project project) {
  final XBreakpointManager bpManager = XDebuggerManager.getInstance(project).getBreakpointManager();
  final DartExceptionBreakpointType bpType = XBreakpointType.EXTENSION_POINT_NAME.findExtension(DartExceptionBreakpointType.class);
  final XBreakpoint<DartExceptionBreakpointProperties> breakpoint = bpManager.getDefaultBreakpoint(bpType);
  assert breakpoint != null;
  return breakpoint;
}
 
Example #20
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void registerBreakpoint(@NotNull final XBreakpoint<DartExceptionBreakpointProperties> breakpoint) {
  final VmServiceWrapper vmServiceWrapper = myDebugProcess.getVmServiceWrapper();
  if (vmServiceWrapper != null) {
    vmServiceWrapper.setExceptionPauseMode(getBreakOnExceptionMode(myDebugProcess.getSession(), breakpoint));
  }
}
 
Example #21
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public static XBreakpoint<DartExceptionBreakpointProperties> getDefaultExceptionBreakpoint(@NotNull final Project project) {
  final XBreakpointManager bpManager = XDebuggerManager.getInstance(project).getBreakpointManager();
  final DartExceptionBreakpointType bpType = XBreakpointType.EXTENSION_POINT_NAME.findExtension(DartExceptionBreakpointType.class);
  final XBreakpoint<DartExceptionBreakpointProperties> breakpoint = bpManager.getDefaultBreakpoint(bpType);
  assert breakpoint != null;
  return breakpoint;
}
 
Example #22
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@NotNull
public static ExceptionPauseMode getBreakOnExceptionMode(@NotNull XDebugSession session,
                                                         @Nullable final XBreakpoint<DartExceptionBreakpointProperties> bp) {
  if (session.areBreakpointsMuted()) {
    return ExceptionPauseMode.None;
  }
  if (bp == null) return ExceptionPauseMode.Unhandled; // Default to breaking on unhandled exceptions.
  if (!bp.isEnabled()) return ExceptionPauseMode.None;
  return bp.getProperties().isBreakOnAllExceptions() ? ExceptionPauseMode.All : ExceptionPauseMode.Unhandled;
}
 
Example #23
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void registerBreakpoint(@NotNull final XBreakpoint<DartExceptionBreakpointProperties> breakpoint) {
  final VmServiceWrapper vmServiceWrapper = myDebugProcess.getVmServiceWrapper();
  if (vmServiceWrapper != null) {
    vmServiceWrapper.setExceptionPauseMode(getBreakOnExceptionMode(myDebugProcess.getSession(), breakpoint));
  }
}
 
Example #24
Source File: XLineBreakpointManager.java    From consulo with Apache License 2.0 4 votes vote down vote up
public void queueBreakpointUpdate(final XBreakpoint<?> slave) {
  if (slave instanceof XLineBreakpointImpl<?>) {
    queueBreakpointUpdate((XLineBreakpointImpl<?>)slave);
  }
}
 
Example #25
Source File: XDebuggerTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public XBreakpoint<MyBreakpointProperties> createDefaultBreakpoint(@Nonnull XBreakpointCreator<MyBreakpointProperties> creator) {
  final XBreakpoint<MyBreakpointProperties> breakpoint = creator.createBreakpoint(new MyBreakpointProperties("default"));
  breakpoint.setEnabled(true);
  return breakpoint;
}
 
Example #26
Source File: XDebuggerTestCase.java    From consulo with Apache License 2.0 4 votes vote down vote up
@Override
public String getDisplayText(final XBreakpoint<MyBreakpointProperties> breakpoint) {
  return "";
}
 
Example #27
Source File: XBreakpointManagerTest.java    From consulo with Apache License 2.0 4 votes vote down vote up
private XBreakpoint<MyBreakpointProperties> getSingleBreakpoint() {
  return assertOneElement(myBreakpointManager.getBreakpoints(MY_SIMPLE_BREAKPOINT_TYPE));
}
 
Example #28
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void unregisterBreakpoint(@NotNull final XBreakpoint<DartExceptionBreakpointProperties> breakpoint, final boolean temporary) {
  registerBreakpoint(breakpoint);
}
 
Example #29
Source File: ToggleBreakpointGutterIconAction.java    From consulo with Apache License 2.0 4 votes vote down vote up
ToggleBreakpointGutterIconAction(XBreakpoint<?> breakpoint) {
  super(breakpoint.isEnabled() ? XDebuggerBundle.message("xdebugger.disable.breakpoint.action.text") : XDebuggerBundle.message("xdebugger.enable.breakpoint.action.text"));
  this.myBreakpoint = breakpoint;
}
 
Example #30
Source File: DartExceptionBreakpointHandler.java    From flutter-intellij with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void unregisterBreakpoint(@NotNull final XBreakpoint<DartExceptionBreakpointProperties> breakpoint, final boolean temporary) {
  registerBreakpoint(breakpoint);
}