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
(Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired) protected
RegexFileChanger
(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
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface io.codemodder.CodeChanger
getIncludesExcludesPattern, shouldRun, supports
-
Constructor Details
-
RegexFileChanger
protected RegexFileChanger(Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired) -
RegexFileChanger
protected RegexFileChanger(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.
-