Package net.neoforged.jst.api
Interface SourceTransformer
public interface SourceTransformer
Transformers are created through
plugins, and handle source replacements.
Transformers will be given to picocli for option collection, so they can accept CLI parameters. It is strongly recommended that transformers prefix their options with the transformer name.
-
Method Summary
Modifier and TypeMethodDescriptiondefault booleanafterRun(TransformContext context) Invoked after all source transformations are finished.default booleanbeforeReplacement(FileEntry fileEntry, List<Replacement> replacements) Invoke after replacements are collected for a given file, but before they are applied.default voidbeforeRun(TransformContext context) Invoked before source files are visited for transformation.voidvisitFile(com.intellij.psi.PsiFile psiFile, Replacements replacements) Visit the givenpsiFilefor transformation.
-
Method Details
-
beforeRun
Invoked before source files are visited for transformation.Can be used for loading data from CLI parameters.
- Parameters:
context- the transform context
-
beforeReplacement
Invoke after replacements are collected for a given file, but before they are applied.Can be used to react to or verify the replacements that were collected.
- Parameters:
fileEntry- the file entry being transformedreplacements- the replacements that were collected; read-only- Returns:
trueif the transformation should continue,falseif it should fail
-
afterRun
Invoked after all source transformations are finished.Can be used for post-transformation validation.
- Parameters:
context- the transform context- Returns:
trueif the transformation was successful,falseif it failed
-
visitFile
Visit the givenpsiFilefor transformation.- Parameters:
psiFile- the file being transformedreplacements- the replacement collector, used to replace the value of psi tree elements
-