Package io.codemodder
Class RegexFileChanger
java.lang.Object
io.codemodder.RawFileChanger
io.codemodder.RegexFileChanger
- All Implemented Interfaces:
CodeChanger
This type does the heavy lifting for many protections that can work in a simple
"search-and-replace" pattern for non-Java code.
-
Field Summary
Fields inherited from class io.codemodder.RawFileChanger
reporter
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotected
RegexFileChanger
(Predicate<Path> fileMatcher, Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired) protected
RegexFileChanger
(Predicate<Path> fileMatcher, Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired, CodemodReporterStrategy reporter) -
Method Summary
Modifier and TypeMethodDescriptionabstract String
getReplacementFor
(String matchingSnippet) Given a snippet that matches the regex, return the replacement string.visitFile
(CodemodInvocationContext context) Visit a file.Methods inherited from class io.codemodder.RawFileChanger
getDescription, getIndividualChangeDescription, getReferences, getSummary
-
Constructor Details
-
RegexFileChanger
protected RegexFileChanger(Predicate<Path> fileMatcher, Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired) -
RegexFileChanger
protected RegexFileChanger(Predicate<Path> fileMatcher, Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired, CodemodReporterStrategy reporter)
-
-
Method Details
-
visitFile
Description copied from class:RawFileChanger
Visit a file. It is up to the subtype to make sure the file is something to be changed and perform all the changing.- Specified by:
visitFile
in classRawFileChanger
- Returns:
- a list of changes that were made to the file
- Throws:
IOException
-
getReplacementFor
Given a snippet that matches the regex, return the replacement string. Some weavers will just delete the snippet, others will wrap it in something, etc.
-