Package com.google.errorprone.refaster
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
public abstract class Template<M extends TemplateMatch> extends Object implements Serializable
Abstract superclass for templates that can be used to search and replace in a Java syntax tree.- Author:
- [email protected] (Louis Wasserman)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description static boolean
AUTOBOXING_DEFAULT
-
Constructor Summary
Constructors Constructor Description Template()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected 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>
annotations()
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.abstract com.google.common.collect.ImmutableMap<String,UType>
expressionArgumentTypes()
abstract Iterable<M>
match(com.sun.tools.javac.tree.JCTree tree, com.sun.tools.javac.util.Context context)
protected static com.sun.tools.javac.tree.Pretty
pretty(com.sun.tools.javac.util.Context context, Writer writer)
abstract Fix
replace(M match)
abstract com.google.common.collect.ImmutableList<UTypeVar>
templateTypeVariables()
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)
-
-
-
Field Detail
-
AUTOBOXING_DEFAULT
public static final boolean AUTOBOXING_DEFAULT
- See Also:
- Constant Field Values
-
-
Method Detail
-
annotations
public abstract com.google.common.collect.ImmutableClassToInstanceMap<Annotation> annotations()
-
templateTypeVariables
public abstract com.google.common.collect.ImmutableList<UTypeVar> templateTypeVariables()
-
expressionArgumentTypes
public abstract com.google.common.collect.ImmutableMap<String,UType> expressionArgumentTypes()
-
match
public abstract Iterable<M> match(com.sun.tools.javac.tree.JCTree tree, com.sun.tools.javac.util.Context context)
-
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)
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.
-
typecheck
@Nullable 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)
-
pretty
protected static com.sun.tools.javac.tree.Pretty pretty(com.sun.tools.javac.util.Context context, Writer writer)
-
addImports
protected static Fix addImports(Inliner inliner, SuggestedFix.Builder fix)
-
-