Search in sources :

Example 26 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class ReportParam method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    String ns = libTag.getTagLib().getNameSpaceAndSeparator();
    String name = ns + "report";
    // check if tag is direct inside if
    if (!ASMUtil.hasAncestorTag(tag, name))
        throw new EvaluatorException("Wrong Context, tag " + libTag.getFullName() + " must be inside a " + name + " tag");
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException)

Example 27 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class Static method evaluate.

@Override
public void evaluate(Tag tag, TagLibTag libTag) throws EvaluatorException {
    // check parent
    Body body = null;
    String compName = Property.getComponentName(tag);
    boolean isCompChild = false;
    Tag p = ASMUtil.getParentTag(tag);
    if (p != null && (p instanceof TagComponent || getFullname(p, "").equalsIgnoreCase(compName))) {
        isCompChild = true;
        body = p.getBody();
    }
    Tag pp = p != null ? ASMUtil.getParentTag(p) : null;
    if (!isCompChild && pp != null && (p instanceof TagComponent || getFullname(pp, "").equalsIgnoreCase(compName))) {
        isCompChild = true;
        body = pp.getBody();
    }
    if (!isCompChild) {
        throw new EvaluatorException("Wrong Context for the the static constructor, " + "a static constructor must inside a component body.");
    }
    // Body body=(Body) tag.getParent();
    List<Statement> children = tag.getBody().getStatements();
    // remove that tag from parent
    ASMUtil.remove(tag);
    StaticBody sb = getStaticBody(body);
    ASMUtil.addStatements(sb, children);
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) Statement(lucee.transformer.bytecode.Statement) StaticBody(lucee.transformer.bytecode.StaticBody) Tag(lucee.transformer.bytecode.statement.tag.Tag) TagLibTag(lucee.transformer.library.tag.TagLibTag) TagComponent(lucee.transformer.bytecode.statement.tag.TagComponent) Body(lucee.transformer.bytecode.Body) StaticBody(lucee.transformer.bytecode.StaticBody)

Example 28 with EvaluatorException

use of lucee.transformer.cfml.evaluator.EvaluatorException in project Lucee by lucee.

the class Try method evaluate.

/**
 * @see lucee.transformer.cfml.evaluator.EvaluatorSupport#evaluate(Element)
 */
@Override
public void evaluate(Tag tag) throws EvaluatorException {
    Body body = tag.getBody();
    int catchCount = 0;
    int noCatchCount = 0;
    int finallyCount = 0;
    // count catch tag and other in body
    if (body != null) {
        List stats = body.getStatements();
        Iterator it = stats.iterator();
        Statement stat;
        Tag t;
        String name;
        while (it.hasNext()) {
            stat = (Statement) it.next();
            if (stat instanceof Tag) {
                t = (Tag) stat;
                name = t.getTagLibTag().getName();
                if (name.equals("finally")) {
                    finallyCount++;
                    noCatchCount++;
                } else if (name.equals("catch"))
                    catchCount++;
                else
                    noCatchCount++;
            } else
                noCatchCount++;
        }
    }
    // check if has Content
    if (catchCount == 0 && finallyCount == 0)
        throw new EvaluatorException("Wrong Context, tag cftry must have at least one tag cfcatch inside or a cffinally tag.");
    if (finallyCount > 1)
        throw new EvaluatorException("Wrong Context, tag cftry can have only one tag cffinally inside.");
    // check if no has Content
    if (noCatchCount == 0) {
        ASMUtil.remove(tag);
    }
}
Also used : EvaluatorException(lucee.transformer.cfml.evaluator.EvaluatorException) Statement(lucee.transformer.bytecode.Statement) Iterator(java.util.Iterator) List(java.util.List) Tag(lucee.transformer.bytecode.statement.tag.Tag) Body(lucee.transformer.bytecode.Body)

Aggregations

EvaluatorException (lucee.transformer.cfml.evaluator.EvaluatorException)28 LitString (lucee.transformer.expression.literal.LitString)10 Attribute (lucee.transformer.bytecode.statement.tag.Attribute)9 Tag (lucee.transformer.bytecode.statement.tag.Tag)6 Body (lucee.transformer.bytecode.Body)5 Statement (lucee.transformer.bytecode.Statement)5 ExprString (lucee.transformer.expression.ExprString)5 Expression (lucee.transformer.expression.Expression)5 TagLibTag (lucee.transformer.library.tag.TagLibTag)5 TemplateException (lucee.runtime.exp.TemplateException)4 Page (lucee.transformer.bytecode.Page)4 TransformerException (lucee.transformer.TransformerException)3 StaticBody (lucee.transformer.bytecode.StaticBody)3 Literal (lucee.transformer.expression.literal.Literal)3 TagIf (lucee.transformer.bytecode.statement.tag.TagIf)2 TagLoop (lucee.transformer.bytecode.statement.tag.TagLoop)2 LitBoolean (lucee.transformer.expression.literal.LitBoolean)2 TagLib (lucee.transformer.library.tag.TagLib)2 SourceCode (lucee.transformer.util.SourceCode)2 Iterator (java.util.Iterator)1