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:
  • 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) throws CouldNotResolveImportException
      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.
      Throws:
      CouldNotResolveImportException
    • typecheck

      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)