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.void
apply
(com.sun.source.util.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 String
final String
toString()
-
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:CodeTransformer
Returns a map of annotation data logically applied to this code transformer.As an example, if a
CodeTransformer
expressed 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) {...} }
@MyCustomAnnotation
from this map.- Specified by:
annotations
in interfaceCodeTransformer
-
apply
public void apply(com.sun.source.util.TreePath path, com.sun.tools.javac.util.Context context, DescriptionListener listener) Description copied from interface:CodeTransformer
Apply recursively from the leaf node in the givenTreePath
.- Specified by:
apply
in interfaceCodeTransformer
-
toString
-