Search in sources :

Example 1 with Breakpoint

use of freemarker.debug.Breakpoint in project liferay-ide by liferay.

the class PortalSourceLookupParticipant method getTemplateName.

private String getTemplateName(IStackFrame frame) throws DebugException {
    String retval = null;
    IThread thread = frame.getThread();
    IBreakpoint[] bps = thread.getBreakpoints();
    if (bps.length == 1) {
        IBreakpoint bp = thread.getBreakpoints()[0];
        retval = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, null);
    } else {
        if (thread instanceof FMThread) {
            FMThread fmThread = (FMThread) thread;
            Breakpoint stepBp = fmThread.getStepBreakpoint();
            if (stepBp != null) {
                // $NON-NLS-1$
                retval = stepBp.getTemplateName().replaceAll(FMDebugTarget.FM_TEMPLATE_SERVLET_CONTEXT, "");
            }
        }
    }
    return retval;
}
Also used : Breakpoint(freemarker.debug.Breakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) FMThread(com.liferay.ide.portal.core.debug.fm.FMThread) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IThread(org.eclipse.debug.core.model.IThread)

Example 2 with Breakpoint

use of freemarker.debug.Breakpoint in project liferay-ide by liferay.

the class FMDebugTarget method resume.

public void resume(FMThread thread) throws DebugException {
    try {
        Breakpoint stepBp = thread.getStepBreakpoint();
        if (stepBp != null) {
            getDebuggerClient().removeBreakpoint(stepBp);
            thread.setStepping(false);
            thread.setStepBreakpoint(null);
        }
        thread.getEnvironment().resume();
        this.fmStackFrames = EMPTY_STACK_FRAMES;
        resumed(DebugEvent.CLIENT_REQUEST);
    } catch (RemoteException e) {
        throw new DebugException(PortalCore.createErrorStatus(e));
    }
}
Also used : Breakpoint(freemarker.debug.Breakpoint) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) RemoteException(java.rmi.RemoteException) DebugException(org.eclipse.debug.core.DebugException)

Example 3 with Breakpoint

use of freemarker.debug.Breakpoint in project freemarker by apache.

the class RmiDebuggerService method registerTemplateSpi.

@Override
void registerTemplateSpi(Template template) {
    String templateName = template.getName();
    synchronized (templateDebugInfos) {
        TemplateDebugInfo tdi = createTemplateDebugInfo(templateName);
        tdi.templates.add(new TemplateReference(templateName, template, refQueue));
        // Inject already defined breakpoints into the template
        for (Iterator iter = tdi.breakpoints.iterator(); iter.hasNext(); ) {
            Breakpoint breakpoint = (Breakpoint) iter.next();
            insertDebugBreak(template, breakpoint);
        }
    }
}
Also used : Breakpoint(freemarker.debug.Breakpoint) Iterator(java.util.Iterator)

Example 4 with Breakpoint

use of freemarker.debug.Breakpoint in project freemarker by apache.

the class RmiDebuggerService method addBreakpoint.

void addBreakpoint(Breakpoint breakpoint) {
    String templateName = breakpoint.getTemplateName();
    synchronized (templateDebugInfos) {
        TemplateDebugInfo tdi = createTemplateDebugInfo(templateName);
        List breakpoints = tdi.breakpoints;
        int pos = Collections.binarySearch(breakpoints, breakpoint);
        if (pos < 0) {
            // Add to the list of breakpoints
            breakpoints.add(-pos - 1, breakpoint);
            // Inject the breakpoint into all templates with this name
            for (Iterator iter = tdi.templates.iterator(); iter.hasNext(); ) {
                TemplateReference ref = (TemplateReference) iter.next();
                Template t = ref.getTemplate();
                if (t == null) {
                    iter.remove();
                } else {
                    insertDebugBreak(t, breakpoint);
                }
            }
        }
    }
}
Also used : Iterator(java.util.Iterator) ArrayList(java.util.ArrayList) List(java.util.List) Breakpoint(freemarker.debug.Breakpoint) Template(freemarker.template.Template)

Example 5 with Breakpoint

use of freemarker.debug.Breakpoint in project liferay-ide by liferay.

the class FMDebugTarget method addRemoteBreakpoints.

public void addRemoteBreakpoints(final Debugger debugger, final IBreakpoint[] bps) throws RemoteException {
    final List<Breakpoint> remoteBps = new ArrayList<Breakpoint>();
    for (IBreakpoint bp : bps) {
        final int line = bp.getMarker().getAttribute(IMarker.LINE_NUMBER, -1);
        final String templateName = bp.getMarker().getAttribute(ILRDebugConstants.FM_TEMPLATE_NAME, null);
        final String remoteTemplateName = createRemoteTemplateName(templateName);
        if (!CoreUtil.isNullOrEmpty(remoteTemplateName) && line > -1) {
            remoteBps.add(new Breakpoint(remoteTemplateName, line));
        }
    }
    final Job job = new Job("add remote breakpoints") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            IStatus retval = null;
            for (Breakpoint bp : remoteBps) {
                try {
                    debugger.addBreakpoint(bp);
                } catch (RemoteException e) {
                    retval = PortalCore.createErrorStatus(NLS.bind("Could not add remote 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) 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)

Aggregations

Breakpoint (freemarker.debug.Breakpoint)9 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)6 RemoteException (java.rmi.RemoteException)5 ArrayList (java.util.ArrayList)5 Iterator (java.util.Iterator)5 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)5 List (java.util.List)3 CoreException (org.eclipse.core.runtime.CoreException)3 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)3 Job (org.eclipse.core.runtime.jobs.Job)3 DebugException (org.eclipse.debug.core.DebugException)3 Debugger (freemarker.debug.Debugger)2 Template (freemarker.template.Template)2 IStatus (org.eclipse.core.runtime.IStatus)2 FMThread (com.liferay.ide.portal.core.debug.fm.FMThread)1 DebuggedEnvironment (freemarker.debug.DebuggedEnvironment)1 IThread (org.eclipse.debug.core.model.IThread)1