/rewrite-templating

Automated templating using code snippets.

Primary LanguageJavaApache License 2.0Apache-2.0

Rewrite Templating

Support before/after templating as seen in Google Refaster.

ci Apache 2.0 Maven Central Revved up by Develocity Contributing Guide

Input

Allows you to defined one or more @BeforeTemplate annotated methods and a single @AfterTemplate method.

package foo;

import com.google.errorprone.refaster.annotation.AfterTemplate;
import com.google.errorprone.refaster.annotation.BeforeTemplate;

public class UseStringIsEmpty {
    @BeforeTemplate
    boolean before(String s) {
        return s.length() > 0;
    }

    @AfterTemplate
    boolean after(String s) {
        return !s.isEmpty();
    }
}

Output

This results in a recipe that can be used to transform code that matches the @BeforeTemplate to the @AfterTemplate.

Contributing

We appreciate all types of contributions. See the contributing guide for detailed instructions on how to get started.