Search in sources :

Example 16 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project dbeaver by dbeaver.

the class ToggleProcedureBreakpointTarget method toggleLineBreakpoints.

@Override
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    IEditorPart editorPart = (IEditorPart) part;
    IResource resource = extractResource(editorPart, selection);
    if (resource == null) {
        return;
    }
    DBSObject databaseObject = DebugUI.extractDatabaseObject(editorPart);
    if (databaseObject == null) {
        return;
    }
    DBNDatabaseNode node = DBeaverCore.getInstance().getNavigatorModel().getNodeByObject(databaseObject);
    if (node == null) {
        return;
    }
    String nodeItemPath = node.getNodeItemPath();
    ITextSelection textSelection = (ITextSelection) selection;
    int lineNumber = textSelection.getStartLine();
    IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(DebugCore.MODEL_IDENTIFIER_DATABASE);
    for (int i = 0; i < breakpoints.length; i++) {
        IBreakpoint breakpoint = breakpoints[i];
        if (breakpoint instanceof IDatabaseBreakpoint) {
            IDatabaseBreakpoint databaseBreakpoint = (IDatabaseBreakpoint) breakpoint;
            if (nodeItemPath.equals(databaseBreakpoint.getNodePath())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    DebugUITools.deleteBreakpoints(new IBreakpoint[] { breakpoint }, part.getSite().getShell(), null);
                    return;
                }
            }
        }
    }
    int charstart = -1, charend = -1;
    // create line breakpoint (doc line numbers start at 0)
    new DatabaseLineBreakpoint(databaseObject, node, resource, lineNumber + 1, charstart, charend, true);
}
Also used : DBSObject(org.jkiss.dbeaver.model.struct.DBSObject) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint) IEditorPart(org.eclipse.ui.IEditorPart) DBNDatabaseNode(org.jkiss.dbeaver.model.navigator.DBNDatabaseNode) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) DatabaseLineBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint) IDatabaseBreakpoint(org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint)

Example 17 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint in project xtext-eclipse by eclipse.

the class StratumBreakpointAdapterFactory method findExistingBreakpoint.

protected IJavaStratumLineBreakpoint findExistingBreakpoint(IResource res, SourceRelativeURI uri, final int line) throws CoreException {
    IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
    IBreakpoint[] breakpoints = manager.getBreakpoints();
    if (uri == null) {
        for (IBreakpoint breakpoint : breakpoints) {
            IMarker marker = breakpoint.getMarker();
            if (breakpoint instanceof IJavaStratumLineBreakpoint && marker.getResource().equals(res)) {
                final IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) breakpoint;
                if (stratumBreakpoint.getLineNumber() == line) {
                    return stratumBreakpoint;
                }
            }
        }
    } else {
        String uriString = uri.toString();
        for (IBreakpoint breakpoint : breakpoints) {
            IMarker marker = breakpoint.getMarker();
            if (breakpoint instanceof IJavaStratumLineBreakpoint && marker.getResource().equals(res) && uriString.equals(marker.getAttribute(JarFileMarkerAnnotationModel.MARKER_URI))) {
                final IJavaStratumLineBreakpoint stratumBreakpoint = (IJavaStratumLineBreakpoint) breakpoint;
                if (stratumBreakpoint.getLineNumber() == line) {
                    return stratumBreakpoint;
                }
            }
        }
    }
    return null;
}
Also used : IJavaStratumLineBreakpoint(org.eclipse.jdt.debug.core.IJavaStratumLineBreakpoint) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IMarker(org.eclipse.core.resources.IMarker) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 18 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint 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);
    }
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) ITextSelection(org.eclipse.jface.text.ITextSelection) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint)

Example 19 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint 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;
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) ErlangDebugTarget(org.erlide.backend.debug.model.ErlangDebugTarget) CoreException(org.eclipse.core.runtime.CoreException) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IErlangBreakpoint(org.erlide.backend.debug.IErlangBreakpoint) ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) BadLocationException(org.eclipse.jface.text.BadLocationException)

Example 20 with IBreakpoint

use of org.eclipse.debug.core.model.IBreakpoint 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;
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) IErlangBreakpoint(org.erlide.backend.debug.IErlangBreakpoint) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IMarker(org.eclipse.core.resources.IMarker) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Aggregations

IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)36 CoreException (org.eclipse.core.runtime.CoreException)12 IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)12 Breakpoint (nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint)9 IResource (org.eclipse.core.resources.IResource)9 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)9 ArrayList (java.util.ArrayList)6 IJavaBreakpoint (org.eclipse.jdt.debug.core.IJavaBreakpoint)6 IJavaLineBreakpoint (org.eclipse.jdt.debug.core.IJavaLineBreakpoint)6 IStatus (org.eclipse.core.runtime.IStatus)5 ITextSelection (org.eclipse.jface.text.ITextSelection)5 Test (org.junit.Test)5 Breakpoint (freemarker.debug.Breakpoint)4 IMarker (org.eclipse.core.resources.IMarker)4 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)4 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)4 RemoteException (java.rmi.RemoteException)3 Date (java.util.Date)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3