Class RefasterRule<M extends TemplateMatch, T extends Template<M>>
java.lang.Object
com.google.errorprone.refaster.RefasterRule<M,T>
- Type Parameters:
M- The type of a match.T- The type of the template used to find matches and generate replacements.
- All Implemented Interfaces:
CodeTransformer, Serializable
public abstract class RefasterRule<M extends TemplateMatch, T extends Template<M>>
extends Object
implements CodeTransformer, Serializable
A representation of an entire Refaster rule, corresponding to a class with @BeforeTemplates
and @AfterTemplates.
- Author:
- lowasser@google.com (Louis Wasserman)
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionabstract com.google.common.collect.ImmutableClassToInstanceMap<Annotation> Returns a map of annotation data logically applied to this code transformer.voidapply(TreePath path, com.sun.tools.javac.util.Context context, DescriptionListener listener) Apply recursively from the leaf node in the givenTreePath.static RefasterRule<?, ?> create(String qualifiedTemplateClass, Iterable<UTypeVar> typeVariables, Collection<? extends Template<?>> beforeTemplates, Collection<? extends Template<?>> afterTemplates, com.google.common.collect.ImmutableClassToInstanceMap<Annotation> annotations) static RefasterRule<?, ?> create(String qualifiedTemplateClass, Collection<? extends Template<?>> beforeTemplates, Collection<? extends Template<?>> afterTemplates) abstract Stringfinal StringtoString()
-
Method Details
-
create
public static RefasterRule<?,?> create(String qualifiedTemplateClass, Collection<? extends Template<?>> beforeTemplates, Collection<? extends Template<?>> afterTemplates) -
create
public static RefasterRule<?,?> create(String qualifiedTemplateClass, Iterable<UTypeVar> typeVariables, Collection<? extends Template<?>> beforeTemplates, Collection<? extends Template<?>> afterTemplates, com.google.common.collect.ImmutableClassToInstanceMap<Annotation> annotations) -
qualifiedTemplateClass
-
annotations
Description copied from interface:CodeTransformerReturns a map of annotation data logically applied to this code transformer.As an example, if a
CodeTransformerexpressed as a Refaster rule had an annotation applied to it:
You could retrieve the value of@MyCustomAnnotation("value") public class AnnotatedRefasterRule { @BeforeTemplate void before(String x) {...} @AfterTemplate void after(String x) {...} }@MyCustomAnnotationfrom this map.- Specified by:
annotationsin interfaceCodeTransformer
-
apply
public void apply(TreePath path, com.sun.tools.javac.util.Context context, DescriptionListener listener) Description copied from interface:CodeTransformerApply recursively from the leaf node in the givenTreePath.- Specified by:
applyin interfaceCodeTransformer
-
toString
-