Search in sources :

Example 6 with XBreakpoint

use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.

the class JavaBreakpointHandler method registerBreakpoint.

@Override
public void registerBreakpoint(@NotNull XBreakpoint breakpoint) {
    Breakpoint javaBreakpoint = BreakpointManager.getJavaBreakpoint(breakpoint);
    if (javaBreakpoint == null) {
        javaBreakpoint = createJavaBreakpoint(breakpoint);
        breakpoint.putUserData(Breakpoint.DATA_KEY, javaBreakpoint);
    }
    if (javaBreakpoint != null) {
        final Breakpoint bpt = javaBreakpoint;
        BreakpointManager.addBreakpoint(bpt);
        // use schedule not to block initBreakpoints
        myProcess.getManagerThread().schedule(new DebuggerCommandImpl() {

            @Override
            protected void action() throws Exception {
                bpt.createRequest(myProcess);
            }

            @Override
            public Priority getPriority() {
                return Priority.HIGH;
            }
        });
    }
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) DebuggerCommandImpl(com.intellij.debugger.engine.events.DebuggerCommandImpl)

Example 7 with XBreakpoint

use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.

the class FieldBreakpoint method findField.

//protected static FieldBreakpoint create(@NotNull Project project, @NotNull Field field, ObjectReference object, XBreakpoint xBreakpoint) {
//  String fieldName = field.name();
//  int line = 0;
//  Document document = null;
//  try {
//    List locations = field.declaringType().allLineLocations();
//    if(!locations.isEmpty()) {
//      Location location = (Location)locations.get(0);
//      line = location.lineNumber();
//      VirtualFile file = VirtualFileManager.getInstance().findFileByUrl(location.sourcePath());
//      if(file != null) {
//        PsiFile psiFile = PsiManager.getInstance(project).findFile(file);
//        if(psiFile != null) {
//          document = PsiDocumentManager.getInstance(project).getDocument(psiFile);
//        }
//      }
//    }
//  }
//  catch (AbsentInformationException e) {
//    LOG.debug(e);
//  }
//  catch (InternalError e) {
//    LOG.debug(e);
//  }
//
//  if(document == null) return null;
//
//  FieldBreakpoint fieldBreakpoint = new FieldBreakpoint(project, createHighlighter(project, document, line), fieldName, xBreakpoint);
//  if (!fieldBreakpoint.isStatic()) {
//    fieldBreakpoint.addInstanceFilter(object.uniqueID());
//  }
//  return (FieldBreakpoint)fieldBreakpoint.init();
//}
public static PsiField findField(Project project, Document document, int offset) {
    PsiFile file = PsiDocumentManager.getInstance(project).getPsiFile(document);
    if (file == null)
        return null;
    offset = CharArrayUtil.shiftForward(document.getCharsSequence(), offset, " \t");
    PsiElement element = file.findElementAt(offset);
    if (element == null)
        return null;
    PsiField field = PsiTreeUtil.getParentOfType(element, PsiField.class, false);
    int line = document.getLineNumber(offset);
    if (field == null) {
        final PsiField[] fld = { null };
        XDebuggerUtil.getInstance().iterateLine(project, document, line, element1 -> {
            PsiField field1 = PsiTreeUtil.getParentOfType(element1, PsiField.class, false);
            if (field1 != null) {
                fld[0] = field1;
                return false;
            }
            return true;
        });
        field = fld[0];
    }
    return field;
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint)

Example 8 with XBreakpoint

use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.

the class XLineBreakpointManager method updateBreakpoints.

private void updateBreakpoints(@NotNull 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);
}
Also used : XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) SmartList(com.intellij.util.SmartList) TIntHashSet(gnu.trove.TIntHashSet)

Example 9 with XBreakpoint

use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.

the class XDependentBreakpointsTest method testSerialize.

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));
}
Also used : Element(org.jdom.Element) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XLineBreakpoint(com.intellij.xdebugger.breakpoints.XLineBreakpoint)

Example 10 with XBreakpoint

use of com.intellij.xdebugger.breakpoints.XBreakpoint in project intellij-community by JetBrains.

the class XBreakpointsTestCase method getAllBreakpoints.

protected List<XBreakpoint<?>> getAllBreakpoints() {
    final XBreakpointBase<?, ?, ?>[] breakpoints = ApplicationManager.getApplication().runReadAction((Computable<XBreakpointBase<?, ?, ?>[]>) () -> myBreakpointManager.getAllBreakpoints());
    final List<XBreakpoint<?>> result = new ArrayList<>();
    for (XBreakpointBase<?, ?, ?> breakpoint : breakpoints) {
        final XBreakpointType type = breakpoint.getType();
        if (type instanceof MySimpleBreakpointType || type instanceof MyLineBreakpointType) {
            result.add(breakpoint);
        }
    }
    result.sort((o1, o2) -> StringUtil.compare(((MyBreakpointProperties) o1.getProperties()).myOption, ((MyBreakpointProperties) o2.getProperties()).myOption, true));
    return result;
}
Also used : XBreakpointBase(com.intellij.xdebugger.impl.breakpoints.XBreakpointBase) XBreakpoint(com.intellij.xdebugger.breakpoints.XBreakpoint) XBreakpointType(com.intellij.xdebugger.breakpoints.XBreakpointType) ArrayList(java.util.ArrayList)

Aggregations

XBreakpoint (com.intellij.xdebugger.breakpoints.XBreakpoint)11 Breakpoint (com.intellij.debugger.ui.breakpoints.Breakpoint)2 XLineBreakpoint (com.intellij.xdebugger.breakpoints.XLineBreakpoint)2 DebuggerCommandImpl (com.intellij.debugger.engine.events.DebuggerCommandImpl)1 SuspendContextCommandImpl (com.intellij.debugger.engine.events.SuspendContextCommandImpl)1 LocatableEventRequestor (com.intellij.debugger.engine.requests.LocatableEventRequestor)1 StackCapturingLineBreakpoint (com.intellij.debugger.ui.breakpoints.StackCapturingLineBreakpoint)1 TreeClassChooser (com.intellij.ide.util.TreeClassChooser)1 ProcessCanceledException (com.intellij.openapi.progress.ProcessCanceledException)1 PsiClass (com.intellij.psi.PsiClass)1 SmartList (com.intellij.util.SmartList)1 XDebugSession (com.intellij.xdebugger.XDebugSession)1 XBreakpointAdapter (com.intellij.xdebugger.breakpoints.XBreakpointAdapter)1 XBreakpointManager (com.intellij.xdebugger.breakpoints.XBreakpointManager)1 XBreakpointType (com.intellij.xdebugger.breakpoints.XBreakpointType)1 XBreakpointBase (com.intellij.xdebugger.impl.breakpoints.XBreakpointBase)1 XLightBreakpointPropertiesPanel (com.intellij.xdebugger.impl.breakpoints.ui.XLightBreakpointPropertiesPanel)1 PyClass (com.jetbrains.python.psi.PyClass)1 InternalException (com.sun.jdi.InternalException)1 ThreadReference (com.sun.jdi.ThreadReference)1