Website | Source | Recipe Catalog | Authoring Recipes
Moderne is a cloud-hosted commercial implementation of OpenRewrite.
automatically refactor source code by applying recipes to the project Each recipe can perform specific refactoring tasks. These recipes are written in Java code and included in the build process using the OpenRewrite Maven or Gradle plugin. Comes with a variety of built-in recipes for common transformations. Community contributes recipes for others.
Uses "Lossless Semantic Trees" (basically boosted ASTs) to enable more fine-grained input as source to a collection of rules (recipes) that are run over source:
Unlike the traditional Abstract Syntax Tree (AST), OpenRewrite's LST offers a unique set of characteristics that make it possible to perform accurate transformations and searches across a repository:
Type-attributed. Each LST is imbued with type information. For example, when referencing a field, the source code may just refer to it as myField. The OpenRewrite LST for myField, on the other hand, would contain additional information about what the type of myField is, even if it isn't defined in the same source file or even the same project.
Format-preserving. Whitespace before and after LSTs are preserved in the tree so the tree can be printed out to reconstitute the original source code without clobbering formatting. Additionally, refactoring operations that insert code are sensitive to the local style of the code around them and match the local style.
Type attribution is necessary for the accurate matching of patterns. For example, if we are looking for SLF4J log statements and we see a statement like the following, without type attribution how do we know if logger is an SLF4J or a Logback logger?
logger.info("Hi");
Format preservation is necessary if formatting isn't 100% consistent throughout the whole repository.
When you run an OpenRewrite recipe locally:
Last modified 28 April 2025