Framework provided markers
Not everything a Recipe may wish to know about an LST is contained in the LST itself. OpenRewrite attaches Markers to an LST provide Recipes access to relevant metadata. This document provides Recipe authors a reference for what metadata is available and how to access it.
Accessing provided markers
All markers described in this document are found on the root element of the LST. The root LST element varies by language, but they all implement the SourceFile
interface. From anywhere in a Visitor the cursor can be used to access the markers on the root element like so:
Build markers
These markers are language-independent, appearing on source files of all formats.
BuildTool
The BuildTool marker records the type and version of build tool which produced the LST. Available on all LSTs produced by one of our build tool plugins.
BuildEnvironment
The subtypes of BuildEnvironment record information on the continuous integration environment from within which the LST was produced. Available on all LSTs produced from a supported CI environment.
Supported CI environments:
GitProvenance
The GitProvenance marker records Git branch, origin, and change hash. Available on all LSTs produced from a Git repository.
Java Markers
NamedStyles
NamedStyles is a named collection of styles representing code style/formatting and related configuration options. If not explicitly configured the code style a project uses will be auto-detected. It is available on Java source files.
Checkstyle
The Checkstyle marker is a NamedStyles
which records Checkstyle settings. It is available on Java source files in projects that configure checkstyle.
JavaProject
JavaProject records the publication coordinates (groupId, artifactId, version) of the module which contains the sources. Available on all sources, not only Java sources, in projects where these publication coordinates are configured.
JavaSourceSet
JavaSourceSet records the name (usually "main" or "test") of the source set containing the source file, and list of fully qualified type names present on the classpath. Available on all Java sources, as well as non-Java sources placed in a Java source set's resources directory.
JavaVersion
JavaVersion records the version of Java used to compile the source, including source and target compatibility. Available on all Java sources.
Maven markers
These markers are available on Maven pom.xml sources.
MavenResolutionResult
MavenResolutionResult contains a rich data model of a pom.xml, including full dependency resolution information.
Last updated