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 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

      public abstract String qualifiedTemplateClass()
    • annotations

      public abstract com.google.common.collect.ImmutableClassToInstanceMap<Annotation> 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:

      
       @MyCustomAnnotation("value")
       public class AnnotatedRefasterRule {
          @BeforeTemplate void before(String x) {...}
          @AfterTemplate void after(String x) {...}
       }
       
      You could retrieve the value of @MyCustomAnnotation from this map.
      Specified by:
      annotations in interface CodeTransformer
    • 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 given TreePath.
      Specified by:
      apply in interface CodeTransformer
    • toString

      public final String toString()
      Overrides:
      toString in class Object