Files
2025-11-30 08:45:33 +08:00

8.2 KiB

1Fully Qualified Recipe NameRecipe NameDescription
2org.openrewrite.DeleteSourceFilesDelete filesDelete files by source path.
3org.openrewrite.MoveFileMove a fileMove a file to a different directory. The file name will remain the same.
4org.openrewrite.RenameFileRename a fileRename a file while keeping it in the same directory.
5org.openrewrite.SetFilePermissionsSet file permission attributesSet a file's read write and executable permission attributes.
6org.openrewrite.text.AppendToTextFileAppend to text fileAppends or replaces content of an existing plain text file or creates a new one if it doesn't already exist. Please note that this recipes requires existing plain text files' format to be successfully parsable by OpenRewrite. If a file is left unchanged it might be parsed as a `Quark` rather than plain text. In such case use the `plainTextMask` option. See the [Gradle](https://docs.openrewrite.org/reference/gradle-plugin-configuration#configuring-the-rewrite-dsl) or [Maven](https://openrewrite.github.io/rewrite-maven-plugin/run-mojo.html#plainTextMasks) plugin configuration page.
7org.openrewrite.text.ChangeTextChange textCompletely replaces the contents of the text file with other text. Use together with a `FindSourceFiles` precondition to limit which files are changed.
8org.openrewrite.text.FindAndReplaceFind and replaceTextual find and replace optionally interpreting the search query as a Regular Expression (regex). When operating on source files that are language-specific Lossless Semantic Tree such as Java or XML this operation converts the source file to plain text for the rest of the recipe run. So if you are combining this recipe with language-specific recipes in a single recipe run put all the language-specific recipes before this recipe.
9org.openrewrite.java.AddCommentToImportAdd comment to import statementAdd a comment to an import statement in a Java source file.
10org.openrewrite.java.AddCommentToMethodAdd comment to method declarationsAdd a comment to method declarations in a Java source file.
11org.openrewrite.java.AddCommentToMethodInvocationsAdd comment to method invocationsAdd a comment to method invocations in a Java source file.
12org.openrewrite.java.AddLicenseHeaderAdd license headerAdds license headers to Java source files when missing. Does not override existing license headers.
13org.openrewrite.java.AddLiteralMethodArgumentAdd a literal method argumentAdd a literal `String` or `int` argument to method invocations.
14org.openrewrite.java.AddMethodParameterAdd method parameter to a method declarationAdds a new method parameter to an existing method declaration.
15org.openrewrite.java.AddNullMethodArgumentAdd a `null` method argumentAdd a `null` argument to method invocations.
16org.openrewrite.java.AddOrUpdateAnnotationAttributeAdd or update annotation attributeSome annotations accept arguments. This recipe sets an existing argument to the specified value or adds the argument if it is not already set.
17org.openrewrite.java.ChangeAnnotationAttributeNameChange annotation attribute nameSome annotations accept arguments. This recipe renames an existing attribute.
18org.openrewrite.java.ChangeMethodAccessLevelChange method access levelChange the access level (public protected private package private) of a method.
19org.openrewrite.java.ChangeMethodInvocationReturnTypeChange method invocation return typeChanges the return type of a method invocation.
20org.openrewrite.java.ChangeMethodNameChange method nameRename a method.
21org.openrewrite.java.ChangeMethodTargetToStaticChange method target to staticChange method invocations to static method calls.
22org.openrewrite.java.ChangeMethodTargetToVariableChange method target to variableChange method invocations to method calls on a variable.
23org.openrewrite.java.ChangePackageRename package nameA recipe that will rename a package name in package statements imports and fully-qualified types.
24org.openrewrite.java.ChangePackageInStringLiteralRename package name in String literalsA recipe that will rename a package name in String literals.
25org.openrewrite.java.ChangeStaticFieldToMethodChange static field access to static method accessMigrate accesses to a static field to invocations of a static method.
26org.openrewrite.java.ChangeTypeChange typeChange a given type to another.
27org.openrewrite.java.ChangeTypeInStringLiteralChange type in String literalsChange a given type to another when used in a String literal.
28org.openrewrite.java.DeleteMethodArgumentDelete method argumentDelete an argument from method invocations.
29org.openrewrite.java.NoStaticImportRemove static importRemoves static imports and replaces them with qualified references. For example `emptyList()` becomes `Collections.emptyList()`.
30org.openrewrite.java.RemoveAnnotationRemove annotationRemove matching annotations wherever they occur.
31org.openrewrite.java.RemoveAnnotationAttributeRemove annotation attributeSome annotations accept arguments. This recipe removes an existing attribute.
32org.openrewrite.java.RemoveImplementsRemove interface implementationsRemoves `implements` clauses from classes implementing the specified interface. Removes `@Overrides` annotations from methods which no longer override anything.
33org.openrewrite.java.RemoveMethodInvocationsRemove method invocationsRemove method invocations if syntactically safe.
34org.openrewrite.java.RemoveUnusedImportsRemove unused importsRemove imports for types that are not referenced. As a precaution against incorrect changes no imports will be removed from any source where unknown types are referenced. The most common cause of unknown types is the use of annotation processors not supported by OpenRewrite such as lombok.
35org.openrewrite.java.ReplaceAnnotationReplace annotationReplace an Annotation with another one if the annotation pattern matches. Only fixed parameters can be set in the replacement.
36org.openrewrite.java.ReplaceConstantReplace constant with literal valueReplace a named constant with a literal value when you wish to remove the old constant. A `String` literal must include escaped quotes.
37org.openrewrite.java.ReplaceConstantWithAnotherConstantReplace constant with another constantReplace a constant with another constant adding/removing import on class if needed.
38org.openrewrite.java.ReplaceMethodInvocationWithConstantReplace method invocation with constantReplace all method invocations matching the method pattern with the specified constant.
39org.openrewrite.java.ReplaceStringLiteralValueReplace `String` literalReplace the value of a complete `String` literal.
40org.openrewrite.java.ReplaceStringLiteralWithConstantReplace String literal with constantReplace String literal with constant adding import on class if needed.
41org.openrewrite.java.ShortenFullyQualifiedTypeReferencesAdd imports for fully qualified references to typesAny fully qualified references to Java types will be replaced with corresponding simple names and import statements provided that it doesn't result in any conflicts with other imports or types declared in the local compilation unit.
42org.openrewrite.text.CreateTextFileCreate text fileCreates a new plain text file.
43org.openrewrite.java.CreateEmptyJavaClassCreate Java classCreate a new empty Java class.
44org.openrewrite.json.CreateJsonFileCreate JSON fileCreate a new JSON file.
45org.openrewrite.properties.CreatePropertiesFileCreate Properties fileCreate a new Properties file.
46org.openrewrite.toml.CreateTomlFileCreate TOML fileCreate a new TOML file.
47org.openrewrite.xml.CreateXmlFileCreate XML fileCreate a new XML file.
48org.openrewrite.yaml.ChangePropertyValueChange YAML propertyChange a YAML property. Expects dot notation for nested YAML mappings similar to how Spring Boot interprets `application.yml` files.
49org.openrewrite.yaml.CoalescePropertiesCoalesce YAML propertiesSimplify nested map hierarchies into their simplest dot separated property form similar to how Spring Boot interprets `application.yml` files.
50org.openrewrite.yaml.MergeYamlMerge YAML snippetMerge a YAML snippet with an existing YAML document.
51org.openrewrite.yaml.UnfoldPropertiesUnfold YAML propertiesTransforms dot-separated property keys in YAML files into nested map hierarchies to enhance clarity and readability or for compatibility with tools expecting structured YAML.