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
ConstructorsModifierConstructorDescriptionprotectedRegexFileChanger(Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired) protectedRegexFileChanger(Pattern pattern, boolean removeEmptyLeftoverLines, List<DependencyGAV> dependenciesRequired, CodemodReporterStrategy reporter) -
Method Summary
Modifier and TypeMethodDescriptionabstract StringgetReplacementFor(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, getSummaryMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:RawFileChangerVisit 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:
visitFilein 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.
-