Search in sources :

Example 11 with ILineBreakpoint

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

the class JAXPDebugTarget method breakpointRemoved.

public void breakpointRemoved(IBreakpoint breakpoint, IMarkerDelta delta) {
    if (supportsBreakpoint(breakpoint)) {
        try {
            ILineBreakpoint lb = (ILineBreakpoint) breakpoint;
            IMarker marker = lb.getMarker();
            if (marker != null) {
                URL file = marker.getResource().getLocation().toFile().toURI().toURL();
                sendRequest(DebugConstants.REQUEST_REMOVE_BREAKPOINT + " " + file + " " + // $NON-NLS-1$ //$NON-NLS-2$
                lb.getLineNumber());
            }
        } catch (CoreException e) {
            JAXPLaunchingPlugin.log(e);
        } catch (MalformedURLException e) {
            JAXPLaunchingPlugin.log(e);
        }
    }
}
Also used : MalformedURLException(java.net.MalformedURLException) CoreException(org.eclipse.core.runtime.CoreException) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IMarker(org.eclipse.core.resources.IMarker) URL(java.net.URL)

Example 12 with ILineBreakpoint

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

the class FMDebugTarget method step.

/*
     * Since current fm debugger doens't have native stepping we must emulate stepping with following steps.
     *
     * 1. Starting at the current stopped line, continue going down the template file to find a
     *    suitable line to stop, ie, a addBreakpoint() that doesn't throw an exception.
     * 2. For the next line if there is already a breakpoint, simply call resume(),
     * 3. If there is no breakpoint already installed, add another one to the next line if that line has a valid
     *    breakpoint location, then resume().
     * 4. Once the next breakpoint is hit, we need to remove the previously added step breakpoint
     */
@SuppressWarnings({ "rawtypes" })
void step(FMThread thread) throws DebugException {
    int currentLineNumber = -1;
    String templateName = null;
    Breakpoint existingStepBp = null;
    final IBreakpoint[] breakpoints = thread.getBreakpoints();
    if (breakpoints.length > 0) {
        try {
            ILineBreakpoint bp = (ILineBreakpoint) breakpoints[0];
            currentLineNumber = bp.getLineNumber();
            templateName = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, "");
        } catch (CoreException e) {
            PortalCore.logError("Could not get breakpoint information.", e);
        }
    } else {
        existingStepBp = thread.getStepBreakpoint();
        currentLineNumber = existingStepBp.getLine();
        templateName = existingStepBp.getTemplateName();
    }
    if (currentLineNumber > -1 && templateName != null) {
        final String remoteTemplateName = createRemoteTemplateName(templateName);
        int stepLine = currentLineNumber + 1;
        Breakpoint existingBp = null;
        Debugger debugCli = getDebuggerClient();
        try {
            List remoteBps = debugCli.getBreakpoints(remoteTemplateName);
            for (Iterator i = remoteBps.iterator(); i.hasNext(); ) {
                Breakpoint remoteBp = (Breakpoint) i.next();
                if (remoteBp.getLine() == stepLine) {
                    existingBp = remoteBp;
                    break;
                }
            }
            if (existingBp == null) {
                boolean addedRemote = false;
                while (!addedRemote) {
                    Breakpoint newBp = new Breakpoint(remoteTemplateName, stepLine++);
                    try {
                        debugCli.addBreakpoint(newBp);
                    } catch (RemoteException e) {
                    // we except to get some remote exceptions if the next line is invalid breakpoint location
                    }
                    List updatedRemoteBps = debugCli.getBreakpoints(remoteTemplateName);
                    if (// our new remote bp was sucessfully added
                    updatedRemoteBps.size() == remoteBps.size() + 1) {
                        addedRemote = true;
                        thread.setStepBreakpoint(newBp);
                        thread.setStepping(true);
                        fireResumeEvent(DebugEvent.RESUME);
                        if (existingStepBp != null) {
                            debugCli.removeBreakpoint(existingStepBp);
                        }
                        thread.getEnvironment().resume();
                    }
                }
            } else {
                // the next line already has a remote breakpoint installed so lets clear our "step" breakpoint
                thread.setStepBreakpoint(null);
                thread.setStepping(false);
                fireResumeEvent(DebugEvent.RESUME);
                if (existingStepBp != null) {
                    debugCli.removeBreakpoint(existingStepBp);
                }
                thread.getEnvironment().resume();
            }
        } catch (RemoteException e) {
            PortalCore.logError("Unable to check remote breakpoints", e);
        }
    } else {
        PortalCore.logError("Unable to step because of missing lineNumber or templateName information.");
    }
}
Also used : Debugger(freemarker.debug.Debugger) Breakpoint(freemarker.debug.Breakpoint) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) CoreException(org.eclipse.core.runtime.CoreException) Iterator(java.util.Iterator) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) ArrayList(java.util.ArrayList) List(java.util.List) RemoteException(java.rmi.RemoteException) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) Breakpoint(freemarker.debug.Breakpoint) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint)

Example 13 with ILineBreakpoint

use of org.eclipse.debug.core.model.ILineBreakpoint 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)

Aggregations

ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)13 CoreException (org.eclipse.core.runtime.CoreException)8 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)8 IResource (org.eclipse.core.resources.IResource)5 ITextSelection (org.eclipse.jface.text.ITextSelection)5 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)3 MalformedURLException (java.net.MalformedURLException)2 URL (java.net.URL)2 ArrayList (java.util.ArrayList)2 IMarker (org.eclipse.core.resources.IMarker)2 IEditorPart (org.eclipse.ui.IEditorPart)2 IErlElement (org.erlide.engine.model.IErlElement)2 IErlElementLocator (org.erlide.engine.model.root.IErlElementLocator)2 IErlModule (org.erlide.engine.model.root.IErlModule)2 DatabaseLineBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.DatabaseLineBreakpoint)2 IDatabaseBreakpoint (org.jkiss.dbeaver.debug.core.breakpoints.IDatabaseBreakpoint)2 DBNDatabaseNode (org.jkiss.dbeaver.model.navigator.DBNDatabaseNode)2 DBSObject (org.jkiss.dbeaver.model.struct.DBSObject)2 FMLineBreakpoint (com.liferay.ide.portal.core.debug.fm.FMLineBreakpoint)1 Breakpoint (freemarker.debug.Breakpoint)1