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;
}
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));
}
}
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);
}
}
}
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);
}
}
}
}
}
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();
}
Aggregations