Class JavaCodeGenerator
java.lang.Object
gg.jte.compiler.java.JavaCodeGenerator
- All Implemented Interfaces:
CodeGenerator, TemplateParserVisitor
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final record(package private) classprivate static final classNested classes/interfaces inherited from interface CodeGenerator
CodeGenerator.TemplateExpressionPart -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate intprivate final List<byte[]> private final LinkedHashSet<ClassDefinition> private final ClassInfoprivate final TemplateCompilerprivate final TemplateConfigprivate CodeBuilder.CodeMarkerprivate final Deque<JavaCodeGenerator.ForLoopStart> private booleanprivate booleanprivate final CodeBuilderprivate intprivate final ConcurrentHashMap<String, List<ParamInfo>> private final LinkedHashSet<TemplateDependency> -
Constructor Summary
ConstructorsConstructorDescriptionJavaCodeGenerator(TemplateCompiler compiler, TemplateConfig config, ConcurrentHashMap<String, List<ParamInfo>> paramOrder, ClassInfo classInfo, LinkedHashSet<ClassDefinition> classDefinitions, LinkedHashSet<TemplateDependency> templateDependencies) -
Method Summary
Modifier and TypeMethodDescriptionprivate voidaddLineInfoField(StringBuilder fields) private voidaddNameField(StringBuilder fields, String name) private voidappendParam(int depth, String param) private voidappendParams(int depth, String name, List<String> params) private StringassignAttributeToVariable(int depth, TemplateParser.HtmlAttribute htmlAttribute) List<byte[]> getCode()private Stringprivate DebugInfointprivate DebugInfogetDebugInfo(int templateLine) private intgetParameterIndex(String name, List<ParamInfo> paramInfos, JavaCodeGenerator.ParamCallInfo paramCallInfo) voidonCodePart(int depth, String codePart) voidonCodeStatement(int depth, String codePart) voidvoidonConditionElse(int depth) voidonConditionElse(int depth, String condition) voidonConditionEnd(int depth) voidonConditionStart(int depth, String condition) voidvoidvoidonForLoopElse(int depth) voidonForLoopEnd(int depth) voidonForLoopStart(int depth, String codePart) voidonHtmlAttributeOutput(int depth, TemplateParser.HtmlTag currentHtmlTag, TemplateParser.HtmlAttribute htmlAttribute) voidonHtmlTagAttributeCodePart(int depth, String codePart, String tagName, String attributeName) voidonHtmlTagBodyCodePart(int depth, String codePart, String tagName) voidvoidonInterceptHtmlTagClosed(int depth, TemplateParser.HtmlTag htmlTag) voidonInterceptHtmlTagOpened(int depth, TemplateParser.HtmlTag htmlTag) voidvoidvoidvoidonTemplateCall(int depth, String name, List<String> params) voidonTextPart(int depth, String textPart) voidonUnsafeCodePart(int depth, String codePart) private voidwriteAttributeMap(TemplateParser.HtmlTag htmlTag) private voidwriteBinaryTextParts(StringBuilder fields) private voidprivate voidprivate voidprivate voidwriteCodePart(int depth, String codePart) private voidwriteIndentation(int depth) private voidwriteIndentation(StringBuilder code, int depth) private voidwriteJavaCodeWithContentSupport(int depth, String code) private voidprivate voidprivate voidprivate voidwriteTextBinary(int depth, String textPart) private voidwriteTextString(int depth, String textPart) Methods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface TemplateParserVisitor
onRawEnd, onRawStart
-
Field Details
-
compiler
-
config
-
paramOrder
-
classInfo
-
javaCode
-
classDefinitions
-
templateDependencies
-
parameters
-
imports
-
binaryTextParts
-
forLoopStack
-
hasWrittenPackage
private boolean hasWrittenPackage -
hasWrittenClass
private boolean hasWrittenClass -
fieldsMarker
-
attributeCounter
private int attributeCounter -
nextForLoopId
private int nextForLoopId
-
-
Constructor Details
-
JavaCodeGenerator
public JavaCodeGenerator(TemplateCompiler compiler, TemplateConfig config, ConcurrentHashMap<String, List<ParamInfo>> paramOrder, ClassInfo classInfo, LinkedHashSet<ClassDefinition> classDefinitions, LinkedHashSet<TemplateDependency> templateDependencies)
-
-
Method Details
-
onImport
- Specified by:
onImportin interfaceTemplateParserVisitor
-
writePackageIfRequired
private void writePackageIfRequired() -
onParam
- Specified by:
onParamin interfaceTemplateParserVisitor
-
writeClass
private void writeClass() -
getContentClass
-
writeTemplateOutputParam
private void writeTemplateOutputParam() -
onParamsComplete
public void onParamsComplete()- Specified by:
onParamsCompletein interfaceTemplateParserVisitor
-
onLineFinished
public void onLineFinished()- Specified by:
onLineFinishedin interfaceTemplateParserVisitor
-
onComplete
public void onComplete()- Specified by:
onCompletein interfaceTemplateParserVisitor
-
addLineInfoField
-
addNameField
-
writeBinaryTextParts
-
writeBinaryTextPartsContent
-
writeBinaryTextPartsConstants
-
onError
- Specified by:
onErrorin interfaceTemplateParserVisitor
-
onError
- Specified by:
onErrorin interfaceTemplateParserVisitor
-
onTextPart
- Specified by:
onTextPartin interfaceTemplateParserVisitor
-
writeTextBinary
-
writeTextString
-
writeText
-
onCodePart
- Specified by:
onCodePartin interfaceTemplateParserVisitor
-
onHtmlTagBodyCodePart
- Specified by:
onHtmlTagBodyCodePartin interfaceTemplateParserVisitor
-
onHtmlTagAttributeCodePart
public void onHtmlTagAttributeCodePart(int depth, String codePart, String tagName, String attributeName) - Specified by:
onHtmlTagAttributeCodePartin interfaceTemplateParserVisitor
-
onUnsafeCodePart
- Specified by:
onUnsafeCodePartin interfaceTemplateParserVisitor
-
writeCodePart
-
onCodeStatement
- Specified by:
onCodeStatementin interfaceTemplateParserVisitor
-
onConditionStart
- Specified by:
onConditionStartin interfaceTemplateParserVisitor
-
onConditionElse
- Specified by:
onConditionElsein interfaceTemplateParserVisitor
-
onConditionElse
public void onConditionElse(int depth) - Specified by:
onConditionElsein interfaceTemplateParserVisitor
-
onConditionEnd
public void onConditionEnd(int depth) - Specified by:
onConditionEndin interfaceTemplateParserVisitor
-
onForLoopStart
- Specified by:
onForLoopStartin interfaceTemplateParserVisitor
-
onForLoopElse
public void onForLoopElse(int depth) - Specified by:
onForLoopElsein interfaceTemplateParserVisitor
-
onForLoopEnd
public void onForLoopEnd(int depth) - Specified by:
onForLoopEndin interfaceTemplateParserVisitor
-
onTemplateCall
- Specified by:
onTemplateCallin interfaceTemplateParserVisitor
-
onInterceptHtmlTagOpened
- Specified by:
onInterceptHtmlTagOpenedin interfaceTemplateParserVisitor
-
onInterceptHtmlTagClosed
- Specified by:
onInterceptHtmlTagClosedin interfaceTemplateParserVisitor
-
onHtmlAttributeOutput
public void onHtmlAttributeOutput(int depth, TemplateParser.HtmlTag currentHtmlTag, TemplateParser.HtmlAttribute htmlAttribute) - Specified by:
onHtmlAttributeOutputin interfaceTemplateParserVisitor
-
assignAttributeToVariable
-
writeAttributeMap
-
writeJavaCodeWithContentSupport
-
getCurrentDebugInfo
-
getDebugInfo
-
getCurrentTemplateLine
public int getCurrentTemplateLine()- Specified by:
getCurrentTemplateLinein interfaceCodeGenerator
-
getParamInfo
- Specified by:
getParamInfoin interfaceCodeGenerator
-
getImports
- Specified by:
getImportsin interfaceCodeGenerator
-
appendParams
-
appendParam
-
getParameterIndex
private int getParameterIndex(String name, List<ParamInfo> paramInfos, JavaCodeGenerator.ParamCallInfo paramCallInfo) -
writeIndentation
private void writeIndentation(int depth) -
writeIndentation
-
getCode
- Specified by:
getCodein interfaceCodeGenerator
-
getBinaryTextParts
- Specified by:
getBinaryTextPartsin interfaceCodeGenerator
-