@@ -0,0 +1,2085 @@
+/*%0A * Copyright 2014 Google Inc. All rights reserved.%0A *%0A * Licensed under the Apache License, Version 2.0 (the %22License%22);%0A * you may not use this file except in compliance with the License.%0A * You may obtain a copy of the License at%0A *%0A *   http://www.apache.org/licenses/LICENSE-2.0%0A *%0A * Unless required by applicable law or agreed to in writing, software%0A * distributed under the License is distributed on an %22AS IS%22 BASIS,%0A * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.%0A * See the License for the specific language governing permissions and%0A * limitations under the License.%0A */%0A%0Apackage com.google.errorprone.refaster;%0A%0Aimport com.google.auto.value.AutoValue;%0Aimport com.google.common.collect.ImmutableClassToInstanceMap;%0Aimport com.google.errorprone.DescriptionListener;%0Aimport com.google.errorprone.ErrorProneScanner;%0Aimport com.google.errorprone.VisitorState;%0Aimport com.google.errorprone.bugpatterns.BugChecker;%0A%0Aimport com.sun.source.tree.CompilationUnitTree;%0Aimport com.sun.tools.javac.util.Context;%0A%0Aimport java.lang.annotation.Annotation;%0A%0A/**%0A * Wrapper around an error-prone %7B@code BugChecker%7D to use it as a %7B@code CodeTransformer%7D.%0A * %0A * @author lowasser@google.com (Louis Wasserman)%0A */%0A@AutoValue%0Apublic abstract class BugCheckerTransformer implements CodeTransformer %7B%0A  public static BugCheckerTransformer create(BugChecker checker) %7B%0A    return new AutoValue_BugCheckerTransformer(checker);%0A  %7D%0A  %0A  abstract BugChecker checker();%0A%0A  @Override%0A  public void apply(CompilationUnitTree tree, Context context, DescriptionListener listener) %7B%0A    new ErrorProneScanner(checker()).scan(tree, new VisitorState(context, listener));%0A  %7D%0A%0A  @SuppressWarnings(%22unchecked%22)%0A  @Override%0A  public ImmutableClassToInstanceMap%3CAnnotation%3E annotations() %7B%0A    ImmutableClassToInstanceMap.Builder%3CAnnotation%3E builder = ImmutableClassToInstanceMap.builder();%0A    for (Annotation annotation : checker().getClass().getDeclaredAnnotations()) %7B%0A      builder.put((Class) annotation.annotationType(), annotation);%0A    %7D%0A    return builder.build();%0A  %7D%0A%7D%0A

Add a wrapper around error-prone BugCheckers to treat them as CodeTransformers ------------- Created by MOE: http://code.google.com/p/moe-java MOE_MIGRATED_REVID=74724574