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