use of org.erlide.backend.debug.ErlangLineBreakpoint in project erlide_eclipse by erlang.
the class ErlangProcess method getBreakpoints.
@Override
public IBreakpoint[] getBreakpoints() {
IStackFrame top = null;
try {
top = getTopStackFrame();
} catch (final DebugException e1) {
// can never happen
}
if (top instanceof ErlangStackFrame) {
final ErlangStackFrame topFrame = (ErlangStackFrame) top;
final IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint[] breakpoints = breakpointManager.getBreakpoints();
for (final IBreakpoint breakpoint : breakpoints) {
if (breakpoint instanceof ErlangLineBreakpoint) {
final ErlangLineBreakpoint lineBreakpoint = (ErlangLineBreakpoint) breakpoint;
try {
if (lineBreakpoint.getModule().equals(topFrame.getModule()) && lineBreakpoint.getLineNumber() == topFrame.getLineNumber()) {
return new IBreakpoint[] { lineBreakpoint };
}
} catch (final DebugException e) {
ErlLogger.warn(e);
} catch (final CoreException e) {
ErlLogger.warn(e);
}
}
}
}
return new IBreakpoint[0];
}
use of org.erlide.backend.debug.ErlangLineBreakpoint in project erlide_eclipse by erlang.
the class ErlLineBreakpointAdapter method toggleLineBreakpoints.
@Override
public void toggleLineBreakpoints(final IWorkbenchPart part, final ISelection selection) throws CoreException {
final ITextEditor textEditor = getEditor(part);
if (textEditor != null) {
final IResource resource = textEditor.getEditorInput().getAdapter(IResource.class);
if (resource == null) {
return;
}
final ITextSelection textSelection = (ITextSelection) selection;
final int lineNumber = textSelection.getStartLine();
final IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL);
for (final IBreakpoint breakpoint : breakpoints) {
if (resource.equals(breakpoint.getMarker().getResource())) {
if (breakpoint instanceof ILineBreakpoint) {
final ILineBreakpoint lineBr = (ILineBreakpoint) breakpoint;
if (lineBr.getLineNumber() == lineNumber + 1) {
breakpoint.delete();
return;
}
}
}
}
// create line breakpoint (doc line numbers start at 0)
final ErlangLineBreakpoint lineBreakpoint = new ErlangLineBreakpoint();
lineBreakpoint.createMarker(resource, lineNumber + 1);
DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
}
}
use of org.erlide.backend.debug.ErlangLineBreakpoint in project erlide_eclipse by erlang.
the class BreakpointMarkerUpdater method updateMarker.
@Override
public boolean updateMarker(final IMarker marker, final IDocument document, final Position position) {
if (position.isDeleted()) {
return false;
}
try {
final int line = MarkerUtilities.getLineNumber(marker);
final int newLine = document.getLineOfOffset(position.getOffset()) + 1;
if (line == newLine) {
return true;
}
final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint breakpoint = manager.getBreakpoint(marker);
if (breakpoint == null) {
return false;
}
if (breakpoint instanceof ErlangLineBreakpoint) {
final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) breakpoint;
final ErlangDebugTarget target = erlangLineBreakpoint.getTarget();
erlangLineBreakpoint.remove(target);
MarkerUtilities.setLineNumber(marker, newLine);
erlangLineBreakpoint.install(target);
return true;
}
// if there exists a breakpoint on the line remove this one
if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker)) {
ensureRanges(document, marker, line);
return lineBreakpointExists(marker.getResource(), line, marker) == null;
}
// a line breakpoint must be removed
if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker) && line == -1) {
return false;
}
MarkerUtilities.setLineNumber(marker, line);
if (BreakpointMarkerUpdater.isLineBreakpointMarker(marker)) {
ensureRanges(document, marker, line);
}
return true;
} catch (final BadLocationException e) {
ErlLogger.error(e);
} catch (final CoreException e) {
ErlLogger.error(e);
}
return false;
}
use of org.erlide.backend.debug.ErlangLineBreakpoint in project erlide_eclipse by erlang.
the class BreakpointMarkerUpdater method lineBreakpointExists.
/**
* Searches for an existing line breakpoint on the specified line in the
* current type that does not match the id of the specified marker
*
* @param resource
* the resource to care about
* @param typeName
* the name of the type the breakpoint is in
* @param lineNumber
* the number of the line the breakpoint is on
* @param currentmarker
* the current marker we are comparing to see if it will be moved
* onto an existing one
* @return an existing line breakpoint on the current line of the given
* resource and type if there is one
* @throws CoreException
*
* @since 3.4
*/
private IErlangBreakpoint lineBreakpointExists(final IResource resource, final int lineNumber, final IMarker currentmarker) throws CoreException {
final IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
final IBreakpoint[] breakpoints = manager.getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL);
final String markerType = currentmarker.getType();
for (IBreakpoint breakpoint1 : breakpoints) {
if (!(breakpoint1 instanceof IErlangBreakpoint)) {
continue;
}
final IErlangBreakpoint breakpoint = (IErlangBreakpoint) breakpoint1;
final IMarker marker = breakpoint.getMarker();
if (marker != null && marker.exists() && marker.getType().equals(markerType) && currentmarker.getId() != marker.getId()) {
if (marker instanceof ErlangLineBreakpoint) {
final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) marker;
if (erlangLineBreakpoint.getLineNumber() == lineNumber) {
return erlangLineBreakpoint;
}
}
}
}
return null;
}
use of org.erlide.backend.debug.ErlangLineBreakpoint in project erlide_eclipse by erlang.
the class ErlangDebugTarget method breakpointAdded.
@Override
public void breakpointAdded(final IBreakpoint breakpoint) {
if (supportsBreakpoint(breakpoint)) {
try {
if (breakpoint.isEnabled() && DebugPlugin.getDefault().getBreakpointManager().isEnabled() || !breakpoint.isRegistered()) {
final ErlangLineBreakpoint erlangLineBreakpoint = (ErlangLineBreakpoint) breakpoint;
erlangLineBreakpoint.install(this);
}
} catch (final CoreException e) {
ErlLogger.error(e);
}
}
}
Aggregations