Search in sources :

Example 31 with IBreakpoint

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

the class FMDebugTarget method removeRemoteBreakpoints.

private void removeRemoteBreakpoints(final IBreakpoint[] breakpoints) {
    final List<Breakpoint> remoteBreakpoints = new ArrayList<Breakpoint>();
    for (IBreakpoint bp : breakpoints) {
        final String templateName = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, "");
        final String remoteTemplateName = createRemoteTemplateName(templateName);
        final Breakpoint remoteBp = new Breakpoint(remoteTemplateName, bp.getMarker().getAttribute(IMarker.LINE_NUMBER, -1));
        remoteBreakpoints.add(remoteBp);
    }
    final Job job = new Job("remove remote breakpoints") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IStatus retval = null;
            for (Breakpoint bp : remoteBreakpoints) {
                try {
                    getDebuggerClient().removeBreakpoint(bp);
                } catch (Exception e) {
                    retval = PortalCore.createErrorStatus(NLS.bind("Unable to get debug client to remove breakpoint: {0}:{1}", new Object[] { bp.getTemplateName(), bp.getLine() }), e);
                    if (retval != Status.OK_STATUS) {
                        PortalCore.logError(retval.getMessage());
                    }
                }
            }
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : Breakpoint(freemarker.debug.Breakpoint) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) IStatus(org.eclipse.core.runtime.IStatus) ArrayList(java.util.ArrayList) Job(org.eclipse.core.runtime.jobs.Job) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) RemoteException(java.rmi.RemoteException)

Example 32 with IBreakpoint

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

the class FMLineBreakpointAdapter method toggleLineBreakpoints.

public void toggleLineBreakpoints(IWorkbenchPart part, ISelection selection) throws CoreException {
    ITextEditor textEditor = getEditor(part);
    if (textEditor != null) {
        IResource resource = (IResource) textEditor.getEditorInput().getAdapter(IResource.class);
        ITextSelection textSelection = (ITextSelection) selection;
        int lineNumber = textSelection.getStartLine();
        IBreakpoint[] breakpoints = DebugPlugin.getDefault().getBreakpointManager().getBreakpoints(ILRDebugConstants.ID_FM_DEBUG_MODEL);
        for (int i = 0; i < breakpoints.length; i++) {
            IBreakpoint breakpoint = breakpoints[i];
            if (resource.equals(breakpoint.getMarker().getResource())) {
                if (((ILineBreakpoint) breakpoint).getLineNumber() == (lineNumber + 1)) {
                    // remove
                    breakpoint.delete();
                    return;
                }
            }
        }
        // create line breakpoint (doc line numbers start at 0)
        FMLineBreakpoint lineBreakpoint = new FMLineBreakpoint(resource, lineNumber + 1);
        DebugPlugin.getDefault().getBreakpointManager().addBreakpoint(lineBreakpoint);
    }
}
Also used : ITextEditor(org.eclipse.ui.texteditor.ITextEditor) FMLineBreakpoint(com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint) 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) FMLineBreakpoint(com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 33 with IBreakpoint

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

the class BreakpointCreator method createBreakpoint.

/**
 * Factory method that creates and returns a {@link Breakpoint} from a given
 * {@link IBreakpoint}.
 */
public static Breakpoint createBreakpoint(IBreakpoint breakpoint) {
    Breakpoint result = new Breakpoint(breakpoint.hashCode(), BreakpointClassifier.classify(breakpoint));
    try {
        result.setEnabled(breakpoint.isEnabled());
        // Make sure the hit count and suspend policy are initialized.
        result.setHitCount(-1);
        if (breakpoint instanceof IJavaBreakpoint) {
            IJavaBreakpoint bp = (IJavaBreakpoint) breakpoint;
            result.setSuspendPolicy(bp.getSuspendPolicy());
            result.setHitCount(bp.getHitCount());
        }
        // Initialize condition fields if available.
        if (breakpoint instanceof IJavaLineBreakpoint) {
            IJavaLineBreakpoint bp = (IJavaLineBreakpoint) breakpoint;
            result.setConditionEnabled(bp.isConditionEnabled());
            result.setCondition(bp.getCondition());
        }
    } catch (CoreException exception) {
        exception.printStackTrace();
    }
    return result;
}
Also used : IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) CoreException(org.eclipse.core.runtime.CoreException)

Example 34 with IBreakpoint

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

the class BreakpointListener method breakpointAdded.

@Override
public void breakpointAdded(IBreakpoint breakpoint) {
    Date timestamp = new Date();
    Breakpoint bp = BreakpointCreator.createBreakpoint(breakpoint);
    breakpoints.put(bp.getHash(), bp);
    BreakpointAddEvent event = new BreakpointAddEvent(bp.getHash(), bp.getBreakpointType(), timestamp);
    TrackingEventManager.addEvent(event);
}
Also used : Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) BreakpointAddEvent(nl.tudelft.watchdog.core.logic.event.eventtypes.debugging.BreakpointAddEvent) Date(java.util.Date)

Example 35 with IBreakpoint

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

the class BreakpointCreatorTest method testCreateBreakpointHitCount.

@Test
public void testCreateBreakpointHitCount() {
    IBreakpoint bp = mock(IBreakpoint.class);
    Breakpoint result = BreakpointCreator.createBreakpoint(bp);
    assertEquals(-1, result.getHitCount());
}
Also used : Breakpoint(nl.tudelft.watchdog.core.logic.breakpoint.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IJavaLineBreakpoint(org.eclipse.jdt.debug.core.IJavaLineBreakpoint) IJavaBreakpoint(org.eclipse.jdt.debug.core.IJavaBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) Test(org.junit.Test)

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