Class UTemplater
java.lang.Object
com.sun.source.util.SimpleTreeVisitor<com.sun.source.tree.Tree,Void>
com.google.errorprone.refaster.UTemplater
- All Implemented Interfaces:
com.sun.source.tree.TreeVisitor<com.sun.source.tree.Tree,
Void>
public class UTemplater
extends com.sun.source.util.SimpleTreeVisitor<com.sun.source.tree.Tree,Void>
Converts a type-checked syntax tree to a portable
UTree
template.- Author:
- lowasser@google.com (Louis Wasserman)
-
Field Summary
Modifier and TypeFieldDescriptionstatic final com.sun.tools.javac.util.Context.Key
<Boolean> Context key to indicate that templates should be treated as BlockTemplates, regardless of their structure.Fields inherited from class com.sun.source.util.SimpleTreeVisitor
DEFAULT_VALUE
-
Constructor Summary
ConstructorDescriptionUTemplater
(Map<String, com.sun.tools.javac.code.Symbol.VarSymbol> freeVariables, com.sun.tools.javac.util.Context context) -
Method Summary
Modifier and TypeMethodDescriptionstatic com.google.common.collect.ImmutableClassToInstanceMap
<Annotation> annotationMap
(com.sun.tools.javac.code.Symbol symbol) static Template
<?> createTemplate
(com.sun.tools.javac.util.Context context, com.sun.source.tree.MethodTree decl) Returns a template based on a method.protected UTree
<?> defaultAction
(com.sun.source.tree.Tree tree, Void v) static com.google.common.collect.ImmutableMap
<String, com.sun.tools.javac.code.Symbol.VarSymbol> freeExpressionVariables
(com.sun.source.tree.MethodTree templateMethodDecl) template
(com.sun.source.tree.ExpressionTree tree) template
(com.sun.source.tree.StatementTree tree) com.sun.source.tree.Tree
template
(com.sun.source.tree.Tree tree) template
(com.sun.tools.javac.code.Type type) templateType
(com.sun.source.tree.Tree tree) com.google.errorprone.refaster.UAnnotatedType
visitAnnotatedType
(com.sun.source.tree.AnnotatedTypeTree tree, Void v) com.google.errorprone.refaster.UAnnotation
visitAnnotation
(com.sun.source.tree.AnnotationTree tree, Void v) com.google.errorprone.refaster.UArrayAccess
visitArrayAccess
(com.sun.source.tree.ArrayAccessTree tree, Void v) com.google.errorprone.refaster.UArrayTypeTree
visitArrayType
(com.sun.source.tree.ArrayTypeTree tree, Void v) com.google.errorprone.refaster.UAssert
visitAssert
(com.sun.source.tree.AssertTree tree, Void v) com.google.errorprone.refaster.UAssign
visitAssignment
(com.sun.source.tree.AssignmentTree tree, Void v) com.google.errorprone.refaster.UBinary
visitBinary
(com.sun.source.tree.BinaryTree tree, Void v) com.google.errorprone.refaster.UBlock
visitBlock
(com.sun.source.tree.BlockTree tree, Void v) com.google.errorprone.refaster.UBreak
visitBreak
(com.sun.source.tree.BreakTree tree, Void v) com.google.errorprone.refaster.UCatch
visitCatch
(com.sun.source.tree.CatchTree tree, Void v) com.google.errorprone.refaster.UClassDecl
visitClass
(com.sun.source.tree.ClassTree tree, Void v) com.google.errorprone.refaster.UAssignOp
visitCompoundAssignment
(com.sun.source.tree.CompoundAssignmentTree tree, Void v) visitConditionalExpression
(com.sun.source.tree.ConditionalExpressionTree tree, Void v) com.google.errorprone.refaster.UContinue
visitContinue
(com.sun.source.tree.ContinueTree tree, Void v) com.google.errorprone.refaster.UDoWhileLoop
visitDoWhileLoop
(com.sun.source.tree.DoWhileLoopTree tree, Void v) com.google.errorprone.refaster.USkip
visitEmptyStatement
(com.sun.source.tree.EmptyStatementTree tree, Void v) com.google.errorprone.refaster.UEnhancedForLoop
visitEnhancedForLoop
(com.sun.source.tree.EnhancedForLoopTree tree, Void v) visitExpressionStatement
(com.sun.source.tree.ExpressionStatementTree tree, Void v) com.google.errorprone.refaster.UForLoop
visitForLoop
(com.sun.source.tree.ForLoopTree tree, Void v) visitIdentifier
(com.sun.source.tree.IdentifierTree tree, Void v) com.google.errorprone.refaster.UIf
com.google.errorprone.refaster.UInstanceOf
visitInstanceOf
(com.sun.source.tree.InstanceOfTree tree, Void v) com.google.errorprone.refaster.UIntersectionType
visitIntersectionType
(com.sun.source.tree.IntersectionTypeTree tree, Void v) com.google.errorprone.refaster.ULabeledStatement
visitLabeledStatement
(com.sun.source.tree.LabeledStatementTree tree, Void v) com.google.errorprone.refaster.ULambda
visitLambdaExpression
(com.sun.source.tree.LambdaExpressionTree tree, Void v) visitLiteral
(com.sun.source.tree.LiteralTree tree, Void v) com.google.errorprone.refaster.UMemberReference
visitMemberReference
(com.sun.source.tree.MemberReferenceTree tree, Void v) visitMemberSelect
(com.sun.source.tree.MemberSelectTree tree, Void v) com.google.errorprone.refaster.UMethodDecl
visitMethod
(com.sun.source.tree.MethodTree decl, Void v) visitMethodInvocation
(com.sun.source.tree.MethodInvocationTree tree, Void v) com.google.errorprone.refaster.UModifiers
visitModifiers
(com.sun.source.tree.ModifiersTree modifiers, Void v) com.google.errorprone.refaster.UNewArray
visitNewArray
(com.sun.source.tree.NewArrayTree tree, Void v) com.google.errorprone.refaster.UNewClass
visitNewClass
(com.sun.source.tree.NewClassTree tree, Void v) com.google.errorprone.refaster.UTypeApply
visitParameterizedType
(com.sun.source.tree.ParameterizedTypeTree tree, Void v) com.google.errorprone.refaster.UParens
visitParenthesized
(com.sun.source.tree.ParenthesizedTree tree, Void v) com.google.errorprone.refaster.UPrimitiveTypeTree
visitPrimitiveType
(com.sun.source.tree.PrimitiveTypeTree tree, Void v) visitReturn
(com.sun.source.tree.ReturnTree tree, Void v) com.google.errorprone.refaster.USynchronized
visitSynchronized
(com.sun.source.tree.SynchronizedTree tree, Void v) com.google.errorprone.refaster.UThrow
visitThrow
(com.sun.source.tree.ThrowTree tree, Void v) com.google.errorprone.refaster.UTry
com.google.errorprone.refaster.UTypeCast
visitTypeCast
(com.sun.source.tree.TypeCastTree tree, Void v) com.google.errorprone.refaster.UTypeParameter
visitTypeParameter
(com.sun.source.tree.TypeParameterTree tree, Void v) com.google.errorprone.refaster.UUnary
visitUnary
(com.sun.source.tree.UnaryTree tree, Void v) com.google.errorprone.refaster.UUnionType
visitUnionType
(com.sun.source.tree.UnionTypeTree tree, Void v) visitVariable
(com.sun.source.tree.VariableTree tree, Void v) com.google.errorprone.refaster.UWhileLoop
visitWhileLoop
(com.sun.source.tree.WhileLoopTree tree, Void v) com.google.errorprone.refaster.UWildcard
visitWildcard
(com.sun.source.tree.WildcardTree tree, Void v) Methods inherited from class com.sun.source.util.SimpleTreeVisitor
visit, visit, visitAnyPattern, visitBindingPattern, visitCase, visitCompilationUnit, visitConstantCaseLabel, visitDeconstructionPattern, visitDefaultCaseLabel, visitErroneous, visitExports, visitImport, visitModule, visitOpens, visitOther, visitPackage, visitPatternCaseLabel, visitProvides, visitRequires, visitSwitch, visitSwitchExpression, visitUses, visitYield
-
Field Details
-
REQUIRE_BLOCK_KEY
Context key to indicate that templates should be treated as BlockTemplates, regardless of their structure.
-
-
Constructor Details
-
UTemplater
-
-
Method Details
-
createTemplate
public static Template<?> createTemplate(com.sun.tools.javac.util.Context context, com.sun.source.tree.MethodTree decl) Returns a template based on a method. One-line methods starting with areturn
statement are guessed to be expression templates, and all other methods are guessed to be block templates. -
freeExpressionVariables
public static com.google.common.collect.ImmutableMap<String,com.sun.tools.javac.code.Symbol.VarSymbol> freeExpressionVariables(com.sun.source.tree.MethodTree templateMethodDecl) -
template
public com.sun.source.tree.Tree template(com.sun.source.tree.Tree tree) -
visitMethod
public com.google.errorprone.refaster.UMethodDecl visitMethod(com.sun.source.tree.MethodTree decl, Void v) -
visitModifiers
public com.google.errorprone.refaster.UModifiers visitModifiers(com.sun.source.tree.ModifiersTree modifiers, Void v) -
template
-
templateType
-
visitInstanceOf
public com.google.errorprone.refaster.UInstanceOf visitInstanceOf(com.sun.source.tree.InstanceOfTree tree, Void v) -
visitPrimitiveType
public com.google.errorprone.refaster.UPrimitiveTypeTree visitPrimitiveType(com.sun.source.tree.PrimitiveTypeTree tree, Void v) -
visitLiteral
-
visitParenthesized
public com.google.errorprone.refaster.UParens visitParenthesized(com.sun.source.tree.ParenthesizedTree tree, Void v) -
visitAssignment
public com.google.errorprone.refaster.UAssign visitAssignment(com.sun.source.tree.AssignmentTree tree, Void v) -
visitArrayAccess
public com.google.errorprone.refaster.UArrayAccess visitArrayAccess(com.sun.source.tree.ArrayAccessTree tree, Void v) -
visitAnnotation
public com.google.errorprone.refaster.UAnnotation visitAnnotation(com.sun.source.tree.AnnotationTree tree, Void v) -
visitAnnotatedType
public com.google.errorprone.refaster.UAnnotatedType visitAnnotatedType(com.sun.source.tree.AnnotatedTypeTree tree, Void v) -
visitMemberSelect
-
visitMethodInvocation
-
visitBinary
public com.google.errorprone.refaster.UBinary visitBinary(com.sun.source.tree.BinaryTree tree, Void v) -
visitCompoundAssignment
public com.google.errorprone.refaster.UAssignOp visitCompoundAssignment(com.sun.source.tree.CompoundAssignmentTree tree, Void v) -
visitUnary
-
visitConditionalExpression
public UExpression visitConditionalExpression(com.sun.source.tree.ConditionalExpressionTree tree, Void v) -
visitNewArray
public com.google.errorprone.refaster.UNewArray visitNewArray(com.sun.source.tree.NewArrayTree tree, Void v) -
visitNewClass
public com.google.errorprone.refaster.UNewClass visitNewClass(com.sun.source.tree.NewClassTree tree, Void v) -
visitClass
public com.google.errorprone.refaster.UClassDecl visitClass(com.sun.source.tree.ClassTree tree, Void v) -
visitArrayType
public com.google.errorprone.refaster.UArrayTypeTree visitArrayType(com.sun.source.tree.ArrayTypeTree tree, Void v) -
visitParameterizedType
public com.google.errorprone.refaster.UTypeApply visitParameterizedType(com.sun.source.tree.ParameterizedTypeTree tree, Void v) -
visitUnionType
public com.google.errorprone.refaster.UUnionType visitUnionType(com.sun.source.tree.UnionTypeTree tree, Void v) -
visitWildcard
public com.google.errorprone.refaster.UWildcard visitWildcard(com.sun.source.tree.WildcardTree tree, Void v) -
visitIntersectionType
public com.google.errorprone.refaster.UIntersectionType visitIntersectionType(com.sun.source.tree.IntersectionTypeTree tree, Void v) -
visitTypeParameter
public com.google.errorprone.refaster.UTypeParameter visitTypeParameter(com.sun.source.tree.TypeParameterTree tree, Void v) -
visitTypeCast
public com.google.errorprone.refaster.UTypeCast visitTypeCast(com.sun.source.tree.TypeCastTree tree, Void v) -
visitLambdaExpression
public com.google.errorprone.refaster.ULambda visitLambdaExpression(com.sun.source.tree.LambdaExpressionTree tree, Void v) -
visitMemberReference
public com.google.errorprone.refaster.UMemberReference visitMemberReference(com.sun.source.tree.MemberReferenceTree tree, Void v) -
visitIdentifier
-
template
-
visitTry
-
visitCatch
-
visitExpressionStatement
public UStatement visitExpressionStatement(com.sun.source.tree.ExpressionStatementTree tree, Void v) -
visitReturn
-
visitWhileLoop
public com.google.errorprone.refaster.UWhileLoop visitWhileLoop(com.sun.source.tree.WhileLoopTree tree, Void v) -
visitVariable
-
visitEmptyStatement
public com.google.errorprone.refaster.USkip visitEmptyStatement(com.sun.source.tree.EmptyStatementTree tree, Void v) -
visitForLoop
public com.google.errorprone.refaster.UForLoop visitForLoop(com.sun.source.tree.ForLoopTree tree, Void v) -
visitLabeledStatement
public com.google.errorprone.refaster.ULabeledStatement visitLabeledStatement(com.sun.source.tree.LabeledStatementTree tree, Void v) -
visitBreak
-
visitContinue
public com.google.errorprone.refaster.UContinue visitContinue(com.sun.source.tree.ContinueTree tree, Void v) -
visitBlock
-
visitThrow
-
visitDoWhileLoop
public com.google.errorprone.refaster.UDoWhileLoop visitDoWhileLoop(com.sun.source.tree.DoWhileLoopTree tree, Void v) -
visitEnhancedForLoop
public com.google.errorprone.refaster.UEnhancedForLoop visitEnhancedForLoop(com.sun.source.tree.EnhancedForLoopTree tree, Void v) -
visitSynchronized
public com.google.errorprone.refaster.USynchronized visitSynchronized(com.sun.source.tree.SynchronizedTree tree, Void v) -
visitIf
-
visitAssert
public com.google.errorprone.refaster.UAssert visitAssert(com.sun.source.tree.AssertTree tree, Void v) -
defaultAction
-
template
-
annotationMap
public static com.google.common.collect.ImmutableClassToInstanceMap<Annotation> annotationMap(com.sun.tools.javac.code.Symbol symbol)
-