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;
}
});
}
}
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;
}
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);
}
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));
}
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;
}
Aggregations