use of jetbrick.template.parser.code.TagCode in project jetbrick-template-1x by subchen.
the class JetTemplateCodeVisitor method visitTag_directive.
@Override
public Code visitTag_directive(Tag_directiveContext ctx) {
String text = ctx.getChild(0).getText();
String name = text.substring(5, text.length() - 1).trim();
TagCode tagCode = scopeCode.createTagCode();
tagCode.setTagId(getUid("tag"));
scopeCode = tagCode.getMethodCode();
scopeCode.define(Code.CONTEXT_NAME, TypedKlass.JetContext);
// add body content
scopeCode.setBodyCode(ctx.block().accept(this));
scopeCode = scopeCode.pop();
// finding tag function
Expression_listContext expression_list = ctx.expression_list();
SegmentListCode segmentListCode = (expression_list == null) ? SegmentListCode.EMPTY : (SegmentListCode) expression_list.accept(this);
Class<?>[] parameterTypes = segmentListCode.getParameterTypes(JetTagContext.class);
Method method = resolver.resolveTagMethod(name, parameterTypes);
if (method == null) {
throw reportError("Undefined tag definition: " + getMethodSignature(name, parameterTypes), ctx);
}
tagCode.setMethod(method);
tagCode.setExpressionListCode(segmentListCode);
return tagCode;
}
Aggregations