Search in sources :

Example 6 with IBreakpointManager

use of org.eclipse.debug.core.IBreakpointManager 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];
}
Also used : ErlangLineBreakpoint(org.erlide.backend.debug.ErlangLineBreakpoint) IStackFrame(org.eclipse.debug.core.model.IStackFrame) CoreException(org.eclipse.core.runtime.CoreException) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) DebugException(org.eclipse.debug.core.DebugException) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 7 with IBreakpointManager

use of org.eclipse.debug.core.IBreakpointManager in project erlide_eclipse by erlang.

the class BackendData method addBreakpointProjectsAndModules.

public static Set<String> addBreakpointProjectsAndModules(final Collection<IProject> projects, final List<String> interpretedModules) {
    final IBreakpointManager bpm = DebugPlugin.getDefault().getBreakpointManager();
    final Set<String> result = new HashSet<>(interpretedModules);
    for (final IBreakpoint bp : bpm.getBreakpoints(ErlDebugConstants.ID_ERLANG_DEBUG_MODEL)) {
        final IMarker m = bp.getMarker();
        final IResource r = m.getResource();
        final String name = r.getName();
        if (SourceKind.hasErlExtension(name)) {
            final IProject p = r.getProject();
            if (projects == null || projects.contains(p)) {
                final String s = p.getName() + ":" + name;
                result.add(s);
            }
        }
    }
    return result;
}
Also used : IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IMarker(org.eclipse.core.resources.IMarker) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IResource(org.eclipse.core.resources.IResource) IProject(org.eclipse.core.resources.IProject) HashSet(java.util.HashSet)

Example 8 with IBreakpointManager

use of org.eclipse.debug.core.IBreakpointManager in project webtools.sourceediting by eclipse.

the class ToggleBreakpointsTarget method toggleLineBreakpoints.

/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.debug.ui.actions.IToggleBreakpointsTarget#toggleLineBreakpoints(org.eclipse.ui.IWorkbenchPart,
	 *      org.eclipse.jface.viewers.ISelection)
	 */
public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor editor = part.getAdapter(ITextEditor.class);
    if (selection instanceof ITextSelection) {
        ITextSelection textSelection = (ITextSelection) selection;
        IDocument document = editor.getDocumentProvider().getDocument(editor.getEditorInput());
        int lineNumber = -1;
        try {
            lineNumber = document.getLineOfOffset(textSelection.getOffset());
        } catch (BadLocationException e) {
        }
        if (lineNumber >= 0) {
            ToggleBreakpointAction toggler = new ToggleBreakpointAction(editor, null);
            toggler.update();
            if (toggler.isEnabled()) {
                IResource resource = toggler.getResource();
                AbstractMarkerAnnotationModel model = toggler.getAnnotationModel();
                IBreakpoint[] breakpoints = getBreakpoints(resource, document, model, lineNumber);
                if (breakpoints.length > 0) {
                    IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
                    for (int i = 0; i < breakpoints.length; i++) {
                        breakpoints[i].getMarker().delete();
                        breakpointManager.removeBreakpoint(breakpoints[i], true);
                    }
                } else {
                    toggler.createBreakpoints(lineNumber + 1);
                }
            }
        }
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) AbstractMarkerAnnotationModel(org.eclipse.ui.texteditor.AbstractMarkerAnnotationModel) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) ITextSelection(org.eclipse.jface.text.ITextSelection) IDocument(org.eclipse.jface.text.IDocument) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) BadLocationException(org.eclipse.jface.text.BadLocationException) IResource(org.eclipse.core.resources.IResource)

Example 9 with IBreakpointManager

use of org.eclipse.debug.core.IBreakpointManager in project webtools.sourceediting by eclipse.

the class BreakpointRulerAction method getBreakpoints.

protected IBreakpoint[] getBreakpoints(IMarker[] markers) {
    IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
    List breakpoints = new ArrayList(markers.length);
    for (int i = 0; i < markers.length; i++) {
        IBreakpoint breakpoint = manager.getBreakpoint(markers[i]);
        if (breakpoint != null) {
            breakpoints.add(breakpoint);
        }
    }
    return (IBreakpoint[]) breakpoints.toArray(new IBreakpoint[0]);
}
Also used : ArrayList(java.util.ArrayList) IBreakpointManager(org.eclipse.debug.core.IBreakpointManager) ArrayList(java.util.ArrayList) List(java.util.List) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 10 with IBreakpointManager

use of org.eclipse.debug.core.IBreakpointManager in project webtools.sourceediting by eclipse.

the class ToggleBreakpointAction method removeBreakpoints.

protected void removeBreakpoints(int lineNumber) {
    IBreakpointManager breakpointManager = DebugPlugin.getDefault().getBreakpointManager();
    IBreakpoint[] breakpoints = getBreakpoints(getMarkers());
    for (int i = 0; i < breakpoints.length; i++) {
        try {
            breakpointManager.removeBreakpoint(breakpoints[i], true);
        } catch (CoreException e) {
            Logger.logException(e);
        }
    }
}
Also used : 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)

Aggregations

IBreakpointManager (org.eclipse.debug.core.IBreakpointManager)14 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)12 CoreException (org.eclipse.core.runtime.CoreException)7 IMarker (org.eclipse.core.resources.IMarker)4 ArrayList (java.util.ArrayList)3 BadLocationException (org.eclipse.jface.text.BadLocationException)3 ErlangLineBreakpoint (org.erlide.backend.debug.ErlangLineBreakpoint)3 IResource (org.eclipse.core.resources.IResource)2 IStatus (org.eclipse.core.runtime.IStatus)2 DebugException (org.eclipse.debug.core.DebugException)2 IErlangBreakpoint (org.erlide.backend.debug.IErlangBreakpoint)2 HashSet (java.util.HashSet)1 List (java.util.List)1 IProject (org.eclipse.core.resources.IProject)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 Status (org.eclipse.core.runtime.Status)1 DebugPlugin (org.eclipse.debug.core.DebugPlugin)1 ILaunch (org.eclipse.debug.core.ILaunch)1 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)1 IStackFrame (org.eclipse.debug.core.model.IStackFrame)1