translateOptional

fun <T> ParseTreeToASTTransformer.translateOptional(original: ParserRuleContext?): T?

Translate the given node and ensure a certain type will be obtained, if the value is not null. If the value is null, null is returned.

Example:

JVariableDeclarator(
name = pt.variableDeclaratorId().text,
arrayDimensions = mutableListOf(),
initializer = translateOptional(pt.variableInitializer())
)