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:
lowasser@google.com (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

    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)  

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

  • Constructor Details

    • Template

      public Template()
  • Method Details

    • 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)
    • replace

      public abstract Fix replace​(M match)
    • 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)