Class Template<M extends TemplateMatch>
java.lang.Object
com.google.errorprone.refaster.Template<M>
- Type Parameters:
M
- Type of a match for this template.
- All Implemented Interfaces:
Serializable
- Direct Known Subclasses:
BlockTemplate
,ExpressionTemplate
Abstract superclass for templates that can be used to search and replace in a Java syntax tree.
- Author:
- lowasser@google.com (Louis Wasserman)
- See Also:
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected com.sun.tools.javac.util.List
<com.sun.tools.javac.code.Type> actualTypes
(Inliner inliner) Returns a list of the actual types to be matched.protected static Fix
addImports
(Inliner inliner, SuggestedFix.Builder fix) abstract com.google.common.collect.ImmutableClassToInstanceMap
<Annotation> protected com.sun.tools.javac.util.List
<com.sun.tools.javac.code.Type> expectedTypes
(Inliner inliner) Returns a list of the expected types to be matched.match
(com.sun.tools.javac.tree.JCTree tree, com.sun.tools.javac.util.Context context) protected static com.sun.tools.javac.tree.Pretty
abstract Fix
abstract com.google.common.collect.ImmutableList
<UTypeVar> protected com.google.common.base.Optional
<Unifier> typecheck
(Unifier unifier, Inliner inliner, com.sun.tools.javac.util.Warner warner, com.sun.tools.javac.util.List<com.sun.tools.javac.code.Type> expectedTypes, com.sun.tools.javac.util.List<com.sun.tools.javac.code.Type> actualTypes)
-
Constructor Details
-
Template
public Template()
-
-
Method Details
-
annotations
-
templateTypeVariables
-
expressionArgumentTypes
-
match
-
replace
-
expectedTypes
protected com.sun.tools.javac.util.List<com.sun.tools.javac.code.Type> expectedTypes(Inliner inliner) throws CouldNotResolveImportException Returns a list of the expected types to be matched. This consists of the argument types from the @BeforeTemplate method, concatenated with the return types of expression placeholders, sorted by the name of the placeholder method.- Throws:
CouldNotResolveImportException
- if a referenced type could not be resolved
-
actualTypes
protected com.sun.tools.javac.util.List<com.sun.tools.javac.code.Type> actualTypes(Inliner inliner) throws CouldNotResolveImportException Returns a list of the actual types to be matched. This consists of the types of the expressions bound to the @BeforeTemplate method parameters, concatenated with the types of the expressions bound to expression placeholders, sorted by the name of the placeholder method.- Throws:
CouldNotResolveImportException
-
typecheck
-
pretty
protected static com.sun.tools.javac.tree.Pretty pretty(com.sun.tools.javac.util.Context context, Writer writer) -
addImports
-