Class AbstractTransformer
java.lang.Object
ortus.boxlang.compiler.javaboxpiler.transformer.AbstractTransformer
- All Implemented Interfaces:
Transformer
- Direct Known Subclasses:
BoxAccessTransformer,BoxArgumentDeclarationTransformer,BoxArgumentTransformer,BoxArrayLiteralTransformer,BoxAssertTransformer,BoxAssignmentTransformer,BoxBinaryOperationTransformer,BoxBooleanLiteralTransformer,BoxBreakTransformer,BoxBufferOutputTransformer,BoxClassTransformer,BoxClosureTransformer,BoxComparisonOperationTransformer,BoxComponentTransformer,BoxContinueTransformer,BoxDecimalLiteralTransformer,BoxDoTransformer,BoxExpressionInvocationTransformer,BoxExpressionStatementTransformer,BoxForIndexTransformer,BoxForInTransformer,BoxFQNTransformer,BoxFunctionalBIFAccessTransformer,BoxFunctionalMemberAccessTransformer,BoxFunctionDeclarationTransformer,BoxFunctionInvocationTransformer,BoxIdentifierTransformer,BoxIfElseTransformer,BoxImportTransformer,BoxIntegerLiteralTransformer,BoxInterfaceTransformer,BoxLambdaTransformer,BoxMethodInvocationTransformer,BoxNegateOperationTransformer,BoxNewTransformer,BoxNullTransformer,BoxParamTransformer,BoxParenthesisTransformer,BoxRethrowTransformer,BoxReturnTransformer,BoxScopeTransformer,BoxScriptIslandTransformer,BoxScriptTransformer,BoxStatementBlockTransformer,BoxStaticAccessTransformer,BoxStaticInitializerTransformer,BoxStaticMethodInvocationTransformer,BoxStringConcatTransformer,BoxStringLiteralTransformer,BoxStructLiteralTransformer,BoxSwitchTransformer,BoxTemplateIslandTransformer,BoxTernaryOperationTransformer,BoxThrowTransformer,BoxTryTransformer,BoxUnaryOperationTransformer,BoxWhileTransformer
Abstract Transformer class
Implements common functionality used by all the transformer sub classes
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected com.github.javaparser.JavaParserprotected org.slf4j.LoggerLoggerprotected Transpiler -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected com.github.javaparser.ast.NodeAdd cross-reference index entrycom.github.javaparser.ast.expr.ExpressionCreate a Key instance from a string literal.com.github.javaparser.ast.expr.ExpressioncreateKey(BoxExpression expr) Create a Key instance out of any expression.protected StringgenerateArguments(List<BoxArgument> arguments) getExitsAllowed(BoxNode node) protected com.github.javaparser.ast.expr.ExpressionparseExpression(String template, Map<String, String> values) Returns the Java Parser AST nodes for the given templateprotected com.github.javaparser.ast.stmt.StatementparseStatement(String template, Map<String, String> values) Returns the Java Parser AST for the given templateprotected booleanrequiresBooleanCaster(BoxExpression condition) Detects if a statement requires a BooleanCastercom.github.javaparser.ast.Nodeabstract com.github.javaparser.ast.Nodetransform(BoxNode node, TransformerContext context) com.github.javaparser.ast.expr.ExpressiontransformAnnotations(List<BoxAnnotation> annotations) Transforms a collection of annotations in a BoxLang Structcom.github.javaparser.ast.expr.ExpressiontransformAnnotations(List<BoxAnnotation> annotations, Boolean defaultTrue, boolean onlyLiteralValues) Transforms a collection of annotations in a BoxLang Structcom.github.javaparser.ast.expr.ExpressiontransformDocumentation(List<BoxDocumentationAnnotation> documentation) Transforms a collection of documentation annotations in a BoxLang Struct
-
Field Details
-
transpiler
-
javaParser
protected com.github.javaparser.JavaParser javaParser -
logger
protected org.slf4j.Logger loggerLogger
-
-
Constructor Details
-
AbstractTransformer
-
-
Method Details
-
transform
public abstract com.github.javaparser.ast.Node transform(BoxNode node, TransformerContext context) throws IllegalStateException - Specified by:
transformin interfaceTransformer- Throws:
IllegalStateException
-
transform
- Specified by:
transformin interfaceTransformer- Throws:
IllegalStateException
-
parseExpression
protected com.github.javaparser.ast.expr.Expression parseExpression(String template, Map<String, String> values) Returns the Java Parser AST nodes for the given template- Parameters:
template- a string template with the expression to parsevalues- a map of values to be replaced in the template- Returns:
- the Java Parser AST representation of the expression
-
parseStatement
protected com.github.javaparser.ast.stmt.Statement parseStatement(String template, Map<String, String> values) Returns the Java Parser AST for the given template- Parameters:
template- a string template with the statement to parsevalues- a map of values to be replaced in the template- Returns:
- the Java Parser AST representation of the statement
-
createKey
Create a Key instance out of any expression. May optimize requests for the same key more than once in a template- Parameters:
expr- expression to be turned into a Key. May be a literal, or expression- Returns:
- The method call expression
-
createKey
Create a Key instance from a string literal. May optimize requests for the same key more than once in a template- Parameters:
expr- expression to be turned into a Key. May be a literal, or expression- Returns:
- Instance of the Key.of method call expression
-
requiresBooleanCaster
Detects if a statement requires a BooleanCaster- Parameters:
condition- the expression to evaluate- Returns:
- true if the BooleanCaster is required
-
addIndex
protected com.github.javaparser.ast.Node addIndex(com.github.javaparser.ast.Node javaNode, BoxNode boxNode) Add cross-reference index entry- Parameters:
javaNode- Java Parser NodeboxNode- BoxLang Node- Returns:
- the Java Parser Node
-
transformDocumentation
public com.github.javaparser.ast.expr.Expression transformDocumentation(List<BoxDocumentationAnnotation> documentation) Transforms a collection of documentation annotations in a BoxLang Struct- Parameters:
documentation- list of documentation annotation- Returns:
- an Expression node
-
transformAnnotations
public com.github.javaparser.ast.expr.Expression transformAnnotations(List<BoxAnnotation> annotations, Boolean defaultTrue, boolean onlyLiteralValues) Transforms a collection of annotations in a BoxLang Struct- Parameters:
annotations- list of annotation- Returns:
- an Expression node
-
transformAnnotations
public com.github.javaparser.ast.expr.Expression transformAnnotations(List<BoxAnnotation> annotations) Transforms a collection of annotations in a BoxLang Struct- Parameters:
annotations- list of annotation- Returns:
- an Expression node
-
generateArguments
-
getExitsAllowed
-