Search in sources :

Example 1 with DebugModel

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

the class FMValue method getSequenceDetailString.

private String getSequenceDetailString(DebugModel model) {
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    try {
        for (int i = 0; i < model.size(); i++) {
            final DebugModel val = model.get(i);
            final String value = getModelDetailString(val);
            if (value != null) {
                sb.append(value);
                sb.append(',');
            }
        }
    } catch (Exception e) {
        sb.append(e.getMessage());
    }
    String value = sb.toString();
    return value.endsWith(",") ? value.replaceFirst(",$", "]") : value;
}
Also used : DebugModel(freemarker.debug.DebugModel) DebugException(org.eclipse.debug.core.DebugException) TemplateModelException(freemarker.template.TemplateModelException) RemoteException(java.rmi.RemoteException)

Example 2 with DebugModel

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

the class FMValue method getVariables.

public IVariable[] getVariables() throws DebugException {
    if (this.variables == null) {
        List<IVariable> vars = new ArrayList<IVariable>();
        try {
            int types = this.debugModel.getModelTypes();
            if (isHashType(types)) {
                try {
                    String[] keys = this.debugModel.keys();
                    DebugModel[] vals = this.debugModel.get(keys);
                    for (int i = 0; i < keys.length; i++) {
                        DebugModel hashValue = vals[i];
                        if (isValidVariable(hashValue)) {
                            vars.add(new FMVariable(stackFrame, keys[i], hashValue));
                        }
                    }
                } catch (ClassCastException cce) {
                // ignore IDE-1082
                }
            } else if (isCollectionType(types)) {
            // String[] keys = this.debugModel.keys();
            // if( isValidVariable( hashValue ) )
            // {
            // vars.add( new FMVariable( stackFrame, key , debugModel ) );
            // }
            } else if (isSequenceType(types) && isValidSequence(this.debugModel)) {
                int length = this.debugModel.size();
                DebugModel[] vals = this.debugModel.get(0, length);
                for (int i = 0; i < length; i++) {
                    if (isValidVariable(vals[i])) {
                        vars.add(new FMVariable(stackFrame, Integer.toString(i), vals[i]));
                    }
                }
            } else if (isStringType(types) || isNumberType(types) || isBooleanType(types) || isDateType(types)) {
            // no variables
            } else {
                System.out.println("Unknown value: " + getReferenceTypeName(this.debugModel));
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        this.variables = vars.toArray(new IVariable[vars.size()]);
        sortVariables(this.variables);
    }
    return this.variables;
}
Also used : DebugModel(freemarker.debug.DebugModel) IVariable(org.eclipse.debug.core.model.IVariable) ArrayList(java.util.ArrayList) DebugException(org.eclipse.debug.core.DebugException) TemplateModelException(freemarker.template.TemplateModelException) RemoteException(java.rmi.RemoteException)

Example 3 with DebugModel

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

the class FMValue method getCollectionDetailString.

private String getCollectionDetailString(DebugModel model) {
    StringBuilder sb = new StringBuilder();
    sb.append('[');
    try {
        for (int i = 0; i < model.size(); i++) {
            final DebugModel val = model.get(i);
            final String value = getModelDetailString(val);
            if (value != null) {
                sb.append(value);
                sb.append(',');
            }
        }
    } catch (Exception e) {
        sb.append(e.getMessage());
    }
    String value = sb.toString();
    return value.endsWith(",") ? value.replaceFirst(",$", "]") : value;
}
Also used : DebugModel(freemarker.debug.DebugModel) DebugException(org.eclipse.debug.core.DebugException) TemplateModelException(freemarker.template.TemplateModelException) RemoteException(java.rmi.RemoteException)

Example 4 with DebugModel

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

the class FMValue method getHashDetailString.

private String getHashDetailString(DebugModel model) {
    StringBuilder sb = new StringBuilder();
    sb.append('{');
    try {
        for (String key : model.keys()) {
            final DebugModel val = model.get(key);
            final String value = getModelDetailString(val);
            if (value != null) {
                sb.append(key);
                sb.append('=');
                sb.append(value);
                sb.append(',');
            }
        }
    } catch (Exception e) {
        sb.append(e.getMessage());
    }
    String value = sb.toString();
    return value.endsWith(",") ? value.replaceFirst(",$", "}") : value;
}
Also used : DebugModel(freemarker.debug.DebugModel) DebugException(org.eclipse.debug.core.DebugException) TemplateModelException(freemarker.template.TemplateModelException) RemoteException(java.rmi.RemoteException)

Example 5 with DebugModel

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

the class RmiDebugModelImpl method get.

public DebugModel[] get(int fromIndex, int toIndex) throws TemplateModelException, RemoteException {
    DebugModel[] dm = new DebugModel[toIndex - fromIndex];
    TemplateSequenceModel s = (TemplateSequenceModel) model;
    for (int i = fromIndex; i < toIndex; i++) {
        dm[i - fromIndex] = getDebugModel(s.get(i));
    }
    return dm;
}
Also used : TemplateSequenceModel(freemarker.template.TemplateSequenceModel) DebugModel(freemarker.debug.DebugModel)

Aggregations

DebugModel (freemarker.debug.DebugModel)7 TemplateModelException (freemarker.template.TemplateModelException)4 RemoteException (java.rmi.RemoteException)4 DebugException (org.eclipse.debug.core.DebugException)4 ArrayList (java.util.ArrayList)2 TemplateCollectionModel (freemarker.template.TemplateCollectionModel)1 TemplateHashModel (freemarker.template.TemplateHashModel)1 TemplateModelIterator (freemarker.template.TemplateModelIterator)1 TemplateSequenceModel (freemarker.template.TemplateSequenceModel)1 List (java.util.List)1 IVariable (org.eclipse.debug.core.model.IVariable)1