Search in sources :

Example 1 with DebuggedEnvironment

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

the class FMStackFrame method getVariables.

public IVariable[] getVariables() throws DebugException {
    if (this.variables == null) {
        /*
             * Represents the debugger-side mirror of a debugged freemarker.core.Environment object in the remote VM.
             *
             * This interface extends DebugModel, and the properties of the Environment are exposed as hash keys on it.
             * Specifically, the following keys are supported: "currentNamespace", "dataModel", "globalNamespace",
             * "knownVariables", "mainNamespace", and "template".
             *
             * The debug model for the template supports keys
             * "configuration" and "name".
             *
             * The debug model for the configuration supports key "sharedVariables".
             * Additionally, all of the debug models for environment, template, and configuration also support all the
             * setting keys of freemarker.core.Configurable objects.
             */
        boolean advancedView = PortalCore.getPrefs().getBoolean(PortalCore.PREF_ADVANCED_VARIABLES_VIEW, false);
        final DebuggedEnvironment env = this.thread.getEnvironment();
        FMVariable[] topLevelVars = null;
        try {
            topLevelVars = new FMVariable[] { new FMVariable(this, "currentNamespace", env.get("currentNamespace")), new FMVariable(this, "dataModel", env.get("dataModel")), new FMVariable(this, "globalNamespace", env.get("globalNamespace")), new FMVariable(this, "knownVariables", env.get("knownVariables")), new FMVariable(this, "mainNamespace", env.get("mainNamespace")), new FMVariable(this, "template", env.get("template")) {

                @Override
                public IValue getValue() throws DebugException {
                    return new TemplateVMValue(stackFrame, debugModel);
                }
            } };
        } catch (Exception e) {
            PortalCore.logError("Unable to create freemarker variables", e);
        }
        if (topLevelVars != null) {
            if (advancedView) {
                this.variables = topLevelVars;
            } else {
                // collapse all the variables into one list and remove duplicates
                Map<String, IVariable> vars = new HashMap<String, IVariable>();
                for (FMVariable topLevelVar : topLevelVars) {
                    for (IVariable nestedVar : topLevelVar.getValue().getVariables()) {
                        IVariable existingVar = vars.get(nestedVar.getName());
                        if (existingVar == null) {
                            vars.put(nestedVar.getName(), nestedVar);
                        }
                    }
                }
                this.variables = filterVariables(vars.values().toArray(new IVariable[0]));
                sortVariables(this.variables);
            }
        }
    }
    return this.variables;
}
Also used : HashMap(java.util.HashMap) DebuggedEnvironment(freemarker.debug.DebuggedEnvironment) IVariable(org.eclipse.debug.core.model.IVariable) DebugException(org.eclipse.debug.core.DebugException) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) IValue(org.eclipse.debug.core.model.IValue)

Example 2 with DebuggedEnvironment

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

the class FMDebugTarget method resume.

@SuppressWarnings("rawtypes")
public void resume() {
    final Job job = new Job("resume") {

        @Override
        protected IStatus run(IProgressMonitor monitor) {
            try {
                // need to check to see if current thread is stepping and then remove the step breakpoint
                Debugger debugger = getDebuggerClient();
                if (debugger != null) {
                    if (fmThread.isStepping()) {
                        Breakpoint stepBp = fmThread.getStepBreakpoint();
                        debugger.removeBreakpoint(stepBp);
                    }
                    for (Iterator i = debugger.getSuspendedEnvironments().iterator(); i.hasNext(); ) {
                        DebuggedEnvironment env = (DebuggedEnvironment) i.next();
                        try {
                            env.resume();
                        } catch (Exception e) {
                            PortalCore.logError("Could not resume suspended environment", e);
                        }
                    }
                    fmStackFrames = EMPTY_STACK_FRAMES;
                    resumed(DebugEvent.CLIENT_REQUEST);
                }
            } catch (RemoteException e) {
                PortalCore.logError("Could not fully resume suspended environments", e);
            }
            return Status.OK_STATUS;
        }
    };
    job.schedule();
}
Also used : Debugger(freemarker.debug.Debugger) Breakpoint(freemarker.debug.Breakpoint) ILineBreakpoint(org.eclipse.debug.core.model.ILineBreakpoint) IBreakpoint(org.eclipse.debug.core.model.IBreakpoint) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DebuggedEnvironment(freemarker.debug.DebuggedEnvironment) Iterator(java.util.Iterator) Job(org.eclipse.core.runtime.jobs.Job) RemoteException(java.rmi.RemoteException) CoreException(org.eclipse.core.runtime.CoreException) DebugException(org.eclipse.debug.core.DebugException) RemoteException(java.rmi.RemoteException)

Aggregations

DebuggedEnvironment (freemarker.debug.DebuggedEnvironment)2 CoreException (org.eclipse.core.runtime.CoreException)2 DebugException (org.eclipse.debug.core.DebugException)2 Breakpoint (freemarker.debug.Breakpoint)1 Debugger (freemarker.debug.Debugger)1 RemoteException (java.rmi.RemoteException)1 HashMap (java.util.HashMap)1 Iterator (java.util.Iterator)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 Job (org.eclipse.core.runtime.jobs.Job)1 IBreakpoint (org.eclipse.debug.core.model.IBreakpoint)1 ILineBreakpoint (org.eclipse.debug.core.model.ILineBreakpoint)1 IValue (org.eclipse.debug.core.model.IValue)1 IVariable (org.eclipse.debug.core.model.IVariable)1